Code Monkey home page Code Monkey logo

shopify-prime's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

shopify-prime's Issues

Support price rules api

Are there plans to support the price rules api in the near term? Would love to start experimenting with it.

Embedded rate limiting

Hey @nozzlegear, I've been receiving shopify 429 time out errors of late.

What are your thoughts on including a built in rate limited to shopify prime?

Can we get a new release?

I realize the project hasn't been updated in 4 months, but there's lots of new functionality in the latest code. If the project has been abandoned, can we at least get a new release with the updated code?

Running the build npm script

Everytime i try and run the build npm script, im recieving the error

auth/index.ts(56,9): error TS2322: Type 'string' is not assignable to type 'WordArray'

is there a reason why this is happening? I havent modified any of the code yet :(

Add a helper function for making requests with a leaky bucket policy

I've typically had a hard time hitting the API rate limit in C# where, just by virtue of the async/await there, my requests only send one at a time in a foreach loop. But my JS apps make liberal use of Promise.all to group up all my requests at once, and it's easy to get into a situation where the app immediately slams into the rate limit wall and fails because the requests are all racing each other. It would be great to add a leaky bucket helper function to Shopify Prime to help mitigate the rate limit.

Prior work:

Cannot find module "."

I'm getting this error...

Does it need a module to be imported into the app root module?

I.m doing a simple query on my home page..
async getShop(){ const shop: any = await new Shops(this.shop, this.appState.get('access_token')).get(xxxxxx); }

base_service.js:16 Uncaught Error: Cannot find module "."
at webpackMissingModule (base_service.js:16) []
at Object.keys.keys (base_service.js:16) []
at webpack_require (bootstrap 861112a…:54) []
at Object.defineProperty.value (index.js:3) []
at webpack_require (bootstrap 861112a…:54) []
at Object.defineProperty.value (index.js:3) []
at webpack_require (bootstrap 861112a…:54) []
at Object.83 (environment.ts:59) []
at webpack_require (bootstrap 861112a…:54) []
at Object.301 (home.module.ts:44) []
at webpack_require (bootstrap 861112a…:54) []
at Object.299 (app.resolver.ts:16) []
at webpack_require (bootstrap 861112a…:54) []
at Object.297 (app.component.ts:48) []
at webpack_require (bootstrap 861112a…:54) []
at Object.302 (index.ts:1) []
at webpack_require (bootstrap 861112a…:54) []
at Object.292 (main.bundle.js:110) []
at webpack_require (bootstrap 861112a…:54) []
at Object.607 (main.bundle.js:2680) []
at webpack_require (bootstrap 861112a…:54) []
at webpackJsonpCallback (bootstrap 861112a…:25) []
at :3000/main.bundle.js:2:1 []

Better tests!

The tests for Shopify Prime are super goofy. I wanted to be able to test the compiled type definitions for the library, so I had to have a project that installed Shopify Prime and used those type definitions, instead of adding a simple test folder which would have ended up using the source types instead. In the end I had a project within a project, which then npm-installed the source project and did some silly things to subvert the yarn cache.

I'm not 100% on a better solution right now, but an idea off the top of my head would be to at least break the test project out into its own repo, or maybe create a special TravisCI test project that only runs tests when we want to release a new version of the lib.

🤷

Replace node-fetch with got

Planning to replace node-fetch with Axios. I'm not a big fan of the fetch globals polluting the typescript scope.

Issue verifying webhook: app/uninstalled

Hi,

I'm having issues verifying webhooks for the app/uninstalled topic.

Client code:

            const hmacHeader = req.header("X-Shopify-Hmac-SHA256")
            const body = req.body

            isAuthenticWebhook(hmacHeader, JSON.stringify(body), StoreRoute.appApiSecretKey).then((isAuthentic: boolean) => {
                if (isAuthentic) {
                    res.status(200)
                } else {
                    return next(new Error("Request authentication failed"))
                }
            }).catch(err => {
                return next(err)
            })

Parameters:

  • X-Shopify-Hmac-SHA256 header: 0rq/AUU4ba+ErHaHhVzQjZePzlKZLOM
  • POST Body (abbreviated): {"id":1428231,"name":"AMTEST",......"force_ssl":true}
  • I'm using the correct secret api key for my app.

isAuthenticWebhook returns a different value then the header I received from Shopify.

Any ideas? Am I passing in the body correctly? Thanks

Script bin invocations error

In package.json using node ./node_modules/.bin/tsc -p, but from what I have researched, it's unnecessary to call like that.
It breaks on windows, because this script is a shell script, not a node script. Npm already puts ./node_modules/.bin in the PATH environment variable when running scripts, writes a *.cmd file for use with cmd, and a shell script for use with *nix terminal. So just call tsc -p, that is enough.

Question: Webhook validation

Hi, just wondering if the following express middleware will break webhook validation? My webhook validation is failing. Thanks


        this.app.use(bodyParser.json())
        this.app.use(bodyParser.urlencoded({ extended: true }))

Looking for maintainers!

Hello everybody, thanks for your interest in Shopify Prime! When I created this package I had the best intentions to keep it up to date and continue to add new features every week, but as you can tell that hasn't been happening.

The problem is I've personally become burned out on the JS ecosystem and have switched to using compile-to-js languages wherever possible. (If you're into that sort of thing, I'm a huge fan of F#'s Fable compiler which converts F# code to JS.)

Due to that, I don't have a ton of motivation for maintaining a package I rarely use. If anybody is interested, I'd be happy to add one or two new maintainers to this project. You'd also get access to the NPM package where you can publish new updates.

The only requirements I have are:

  1. Don't be rude to people that open issues and pull requests.
  2. New features should have tests.
  3. Never publish a new release until the tests are passing.
  4. Never publish breaking changes unless it's in a new major release (e.g. 1.0.0 => 2.0.0)
  5. Be much more responsive to issues than I am! 😉 I'm not expecting anybody to make this their full time job and it's okay to have issues sit for a couple days when you're busy, but if you're going to be a maintainer you should maintain the package.

Beyond that everything is up to your own discretion. If you want to change the build scripts or tests, go ahead! I know they're garbo. 😉

However, I'm reserving the right to add a small self-promotional banner to the repo/docs for a course I was going to write on building Shopify apps with Shopify Prime (but more than likely that may never happen).

Generated code obscures error stack trace

Hi,

Error: [Shopify Prime] 401 Unauthorized.  🍎     at Assets.<anonymous> (/app/node_modules/shopify-prime/dist/infrastructure/base_service.js:78:23) 🍎     at Generator.next (<anonymous>) 🍎     at fulfilled (/app/node_modules/shopify-prime/dist/infrastructure/base_service.js:4:58) 🍎     at process._tickCallback (internal/process/next_tick.js:68:7)

Such error is thrown from Shopify-Prime library but for some reason it doesn't print full stack trace pointing to the originating line of code from my code.
I guess that it is obscured because of TS->JS compilation and in particular transpilation of async methods to process._tickCallback shims.

Do you know any workaround for this so there is no need to wrap-up the while library in own error rethrows?

Support the [Online Access] and [Offline Access] oauth types

Shopify has announced a new type of access token that you can receive during the OAuth signup flow. For support, this lib will need to add a grants string array property when building an authorization URL. The only known value is per-user.

Leaving the grants array blank will return an access token that's identical to the one that was given before this change, though Shopify now calls this an "offline access" token. Specifying per-user in the grants array will give you the new "online access" token.

This page goes into the difference between the two tokens, but to summarize: the new "online access" token is like a temporary user password to the store. It's guaranteed to respect the user's permissions with the store, and it will expire after the user logs out of their Shopify account.

Don't try to read the package.json

The BaseService module attempts to read the package.json file from two directories above. In most cases this works fine, but webpack and other bundlers can break on this – and there are probably unforeseen cases where Node itself breaks. The only reason we try to read package.json is to write the package version in the UserAgent during API requests. That's probably unnecessary, and there's a better way to do that without breaking scripts (e.g. hardcoding the version in its own module and writing a small script to update it on every npm version command).

Question: How to use Authscope type?

Hi, TSC is complaining about the use of auth scope function params.

            buildAuthorizationUrl(scope, shopUrl, appApikey, redirectUrl).then((url: string) => {
                res.redirect(url)
            }).catch(err => {
                return next(err)
            })

I've tried setting scope to:

  • ["read_orders", "read_products"]
  • AuthScope.read_orders
  • "read_orders"

None of them work :(

TSC is pretty pedantic...

Npm link compile errors

Hi,

I have a fork of this lib cloned locally. I'm trying to npm link the lib as a dependency into another project. I'm getting the following Typescript compilation error:

tsc --outDir ./lib src/index.ts
node_modules/shopify-prime/dist/infrastructure/base_service.d.ts(9,130): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/auth.d.ts(11,31): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/auth.d.ts(20,31): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/auth.d.ts(30,61): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/auth.d.ts(34,70): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/auth.d.ts(43,153): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/auth.d.ts(52,119): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/charges.d.ts(12,29): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/charges.d.ts(18,46): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/charges.d.ts(23,34): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/charges.d.ts(28,27): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/recurring_charges.d.ts(13,38): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/recurring_charges.d.ts(19,46): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/recurring_charges.d.ts(24,34): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/recurring_charges.d.ts(29,27): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/recurring_charges.d.ts(34,25): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/script_tags.d.ts(13,40): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/script_tags.d.ts(18,53): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/script_tags.d.ts(23,46): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/script_tags.d.ts(27,29): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/script_tags.d.ts(32,41): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/script_tags.d.ts(36,25): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/shops.d.ts(13,34): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/shops.d.ts(17,26): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/usage_charges.d.ts(13,61): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/usage_charges.d.ts(20,73): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/usage_charges.d.ts(26,62): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/webhooks.d.ts(14,38): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/webhooks.d.ts(19,51): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/webhooks.d.ts(24,46): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/webhooks.d.ts(28,31): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/webhooks.d.ts(33,43): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/dist/modules/webhooks.d.ts(37,25): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/typings/globals/mocha/index.d.ts(5,5): error TS2300: Duplicate identifier 'slow'.
node_modules/shopify-prime/typings/globals/mocha/index.d.ts(8,5): error TS2300: Duplicate identifier 'timeout'.
node_modules/shopify-prime/typings/globals/mocha/index.d.ts(11,5): error TS2300: Duplicate identifier 'ui'.
node_modules/shopify-prime/typings/globals/mocha/index.d.ts(14,5): error TS2300: Duplicate identifier 'globals'.
node_modules/shopify-prime/typings/globals/mocha/index.d.ts(17,5): error TS2300: Duplicate identifier 'reporter'.
node_modules/shopify-prime/typings/globals/mocha/index.d.ts(20,5): error TS2300: Duplicate identifier 'bail'.
node_modules/shopify-prime/typings/globals/mocha/index.d.ts(23,5): error TS2300: Duplicate identifier 'ignoreLeaks'.
node_modules/shopify-prime/typings/globals/mocha/index.d.ts(26,5): error TS2300: Duplicate identifier 'grep'.
node_modules/shopify-prime/typings/globals/mocha/index.d.ts(96,15): error TS2300: Duplicate identifier 'Mocha'.
node_modules/shopify-prime/typings/globals/mocha/index.d.ts(141,19): error TS2300: Duplicate identifier 'Mocha'.
node_modules/shopify-prime/typings/globals/mocha/index.d.ts(236,5): error TS2300: Duplicate identifier 'export='.
node_modules/shopify-prime/typings/index.d.ts(6,1): error TS6053: File '/Users/Danijel/projects/am/am-api/node_modules/am-api/typings/modules/es6-promise/index.d.ts' not found.
node_modules/shopify-prime/typings/modules/node-fetch/index.d.ts(50,24): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/typings/modules/node-fetch/index.d.ts(51,17): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/typings/modules/node-fetch/index.d.ts(52,21): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/typings/modules/node-fetch/index.d.ts(53,17): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/typings/modules/node-fetch/index.d.ts(54,20): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/typings/modules/node-fetch/index.d.ts(55,17): error TS2304: Cannot find name 'Promise'.
node_modules/shopify-prime/typings/modules/node-fetch/index.d.ts(95,55): error TS2304: Cannot find name 'Promise'.
src/routes/shopify/store.ts(29,35): error TS2345: Argument of type 'string[]' is not assignable to parameter of type '("read_content" | "write_content" | "read_themes" | "write_themes" | "read_products" | "write_pro...'.
  Type 'string' is not assignable to type '"read_content" | "write_content" | "read_themes" | "write_themes" | "read_products" | "write_prod...'.
    Type 'string' is not assignable to type '"write_users"'.
typings/globals/mocha/index.d.ts(5,5): error TS2300: Duplicate identifier 'slow'.
typings/globals/mocha/index.d.ts(8,5): error TS2300: Duplicate identifier 'timeout'.
typings/globals/mocha/index.d.ts(11,5): error TS2300: Duplicate identifier 'ui'.
typings/globals/mocha/index.d.ts(14,5): error TS2300: Duplicate identifier 'globals'.
typings/globals/mocha/index.d.ts(17,5): error TS2300: Duplicate identifier 'reporter'.
typings/globals/mocha/index.d.ts(20,5): error TS2300: Duplicate identifier 'bail'.
typings/globals/mocha/index.d.ts(23,5): error TS2300: Duplicate identifier 'ignoreLeaks'.
typings/globals/mocha/index.d.ts(26,5): error TS2300: Duplicate identifier 'grep'.
typings/globals/mocha/index.d.ts(63,15): error TS2300: Duplicate identifier 'Mocha'.
typings/globals/mocha/index.d.ts(109,19): error TS2300: Duplicate identifier 'Mocha'.
typings/globals/mocha/index.d.ts(201,5): error TS2300: Duplicate identifier 'export='.

My project's ts.config file is:

{
  "compileOnSave": true,
  "compilerOptions": {
    "module": "node",
    "target": "es6",
    "sourceMap": true,
    "removeComments": true,
    "outDir": "/lib"
  },
  "exclude": [
    "node_modules"
  ]
}

I'm using typescript 1.8 stable.

I assumed that by using es6 as my target, that promises would just work. Unfortunately that isn't the case. Any ideas?

Remove the published prop from CustomCollection

This isn't actually returned by Shopify. Devs should be looking at the published_at value instead to determine if a collection is published. If this property is needed for creating or updating a collection, add it as an extra property for those calls:

public create(collection: CustomCollection & {published?: boolean})

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.