@prys/seed 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +94 -94
- package/package.json +38 -38
package/README.md
CHANGED
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
# @prys/seed
|
|
2
|
-
|
|
3
|
-
Backfill for the [Prys](https://prys.io) **Customer CRM**: fills in shop details (Shopify plan, country, store age,
|
|
4
|
-
store contacts) for the stores that installed your Shopify app before you added the Prys identify call.
|
|
5
|
-
|
|
6
|
-
It runs on your side, with your app's own Shopify client. Your access tokens never leave your server; Prys receives
|
|
7
|
-
only the answer to the same shop query as the Customer CRM's step 1 snippet.
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npx @prys/seed --key=<your Prys key>
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Your key is in Prys > Customer CRM > Enrichment (step 1, "Show key").
|
|
14
|
-
|
|
15
|
-
## What it does
|
|
16
|
-
|
|
17
|
-
1. Loads `./app/shopify.server` (the Shopify React Router / Remix template's `shopifyApp()` file, `.ts` or `.js`),
|
|
18
|
-
so your own session storage and token handling are used.
|
|
19
|
-
2. Asks Prys which stores have your app installed (`GET /installs`).
|
|
20
|
-
3. Looks up your app's offline session for each store. Stores without one are skipped; they fill in when the merchant
|
|
21
|
-
next opens your app (your step 1 call).
|
|
22
|
-
4. Shows the counts and a sample, then asks:
|
|
23
|
-
|
|
24
|
-
```
|
|
25
|
-
› loading ./app/shopify.server (your own Shopify config)
|
|
26
|
-
› asking Prys which stores are installed: 8,240
|
|
27
|
-
› 8,102 have an offline session your app can use
|
|
28
|
-
› 138 have none yet; they fill in as they open the app
|
|
29
|
-
› sample:
|
|
30
|
-
|
|
31
|
-
? Read these 8,102 with your app's client and send to Prys? (y/N)
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
**Nothing is read from Shopify or sent to Prys until you answer `y`.** Enter alone means No.
|
|
35
|
-
5. For each store it calls `unauthenticated.admin(shop)`, so your library loads, decrypts and refreshes the token exactly
|
|
36
|
-
as your app does, runs the step 1 shop query and sends the `data` objects to Prys in batches of 200
|
|
37
|
-
(`POST /identify/bulk`), printing what Prys received, stored and rejected per batch:
|
|
38
|
-
|
|
39
|
-
```
|
|
40
|
-
› batch 1: received 200, stored 198, rejected 2 (not_installed 1, dev_store 1)
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
Rejections are normal: `not_installed` (Prys's Partner data shows the store uninstalled), `dev_store` (development
|
|
44
|
-
stores are kept out of the CRM). "Already sent in the last 24 h" means Prys has that store fresh from your step 1 call.
|
|
45
|
-
|
|
46
|
-
## Where to run it
|
|
47
|
-
|
|
48
|
-
From your app's project folder, on a machine where your app runs or can reach the same session storage: the same
|
|
49
|
-
environment variables your app needs (`SHOPIFY_API_KEY`, `SHOPIFY_API_SECRET`, `SHOPIFY_APP_URL`, `SCOPES`, your
|
|
50
|
-
database address) and after `npm install`. A `.env` file in the folder is read for any variable that is not already set.
|
|
51
|
-
|
|
52
|
-
Your `shopify.server` file must export `unauthenticated` and `sessionStorage`, as the template does:
|
|
53
|
-
|
|
54
|
-
```ts
|
|
55
|
-
export const unauthenticated = shopify.unauthenticated;
|
|
56
|
-
export const sessionStorage = shopify.sessionStorage;
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## Options
|
|
60
|
-
|
|
61
|
-
| Option | |
|
|
62
|
-
|---|---|
|
|
63
|
-
| `--key=<key>` | Your app's Prys key. Or set `PRYS_KEY` (keeps it out of your shell history). |
|
|
64
|
-
| `--base-url=<url>` | Prys API address. Default `https://admin.prys.io/api/v1`. Plain `http://` only for localhost. |
|
|
65
|
-
| `--config=<path>` | Your `shopifyApp()` file, if it is not `./app/shopify.server.{ts,js}`. |
|
|
66
|
-
| `--concurrency=<n>` | Stores read at once, 1 to 20 (default 4). Each store has its own Shopify limit. |
|
|
67
|
-
| `--help`, `--version` | |
|
|
68
|
-
|
|
69
|
-
Prys allows 600 calls a minute per key; when it answers `rate_limited` the CLI waits as told and sends the same batch
|
|
70
|
-
again. The key is never printed.
|
|
71
|
-
|
|
72
|
-
## Other frameworks
|
|
73
|
-
|
|
74
|
-
Node / Express, Laravel, Rails and other backends: Prys > Customer CRM > Enrichment > step 2 shows a short script
|
|
75
|
-
for each, using the same two calls (`GET /installs`, `POST /identify/bulk`).
|
|
76
|
-
|
|
77
|
-
## Requirements
|
|
78
|
-
|
|
79
|
-
Node.js 18.18 or newer. TypeScript config files are loaded with [tsx](https://tsx.is) (installed with this package).
|
|
80
|
-
|
|
81
|
-
## Development
|
|
82
|
-
|
|
83
|
-
```bash
|
|
84
|
-
npm install
|
|
85
|
-
npm test
|
|
86
|
-
npm run check-query -- <front-end-crm>/app/src/sections/Dashboards/CustomerCrm/Enrichment/snippetTemplates.ts
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
`npm test` runs the CLI against a stub Prys server and a fake Shopify app (TypeScript and JavaScript
|
|
90
|
-
`shopify.server`). `check-query` fails when the shop query here and the CRM screen's step 1 query drift apart.
|
|
91
|
-
|
|
92
|
-
## License
|
|
93
|
-
|
|
94
|
-
MIT
|
|
1
|
+
# @prys/seed
|
|
2
|
+
|
|
3
|
+
Backfill for the [Prys](https://prys.io) **Customer CRM**: fills in shop details (Shopify plan, country, store age,
|
|
4
|
+
store contacts) for the stores that installed your Shopify app before you added the Prys identify call.
|
|
5
|
+
|
|
6
|
+
It runs on your side, with your app's own Shopify client. Your access tokens never leave your server; Prys receives
|
|
7
|
+
only the answer to the same shop query as the Customer CRM's step 1 snippet.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx @prys/seed --key=<your Prys key>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Your key is in Prys > Customer CRM > Enrichment (step 1, "Show key").
|
|
14
|
+
|
|
15
|
+
## What it does
|
|
16
|
+
|
|
17
|
+
1. Loads `./app/shopify.server` (the Shopify React Router / Remix template's `shopifyApp()` file, `.ts` or `.js`),
|
|
18
|
+
so your own session storage and token handling are used.
|
|
19
|
+
2. Asks Prys which stores have your app installed (`GET /installs`).
|
|
20
|
+
3. Looks up your app's offline session for each store. Stores without one are skipped; they fill in when the merchant
|
|
21
|
+
next opens your app (your step 1 call).
|
|
22
|
+
4. Shows the counts and a sample, then asks:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
› loading ./app/shopify.server (your own Shopify config)
|
|
26
|
+
› asking Prys which stores are installed: 8,240
|
|
27
|
+
› 8,102 have an offline session your app can use
|
|
28
|
+
› 138 have none yet; they fill in as they open the app
|
|
29
|
+
› sample: juniper-frames, fable-books, tide-swim
|
|
30
|
+
|
|
31
|
+
? Read these 8,102 with your app's client and send to Prys? (y/N)
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Nothing is read from Shopify or sent to Prys until you answer `y`.** Enter alone means No.
|
|
35
|
+
5. For each store it calls `unauthenticated.admin(shop)`, so your library loads, decrypts and refreshes the token exactly
|
|
36
|
+
as your app does, runs the step 1 shop query and sends the `data` objects to Prys in batches of 200
|
|
37
|
+
(`POST /identify/bulk`), printing what Prys received, stored and rejected per batch:
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
› batch 1: received 200, stored 198, rejected 2 (not_installed 1, dev_store 1)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Rejections are normal: `not_installed` (Prys's Partner data shows the store uninstalled), `dev_store` (development
|
|
44
|
+
stores are kept out of the CRM). "Already sent in the last 24 h" means Prys has that store fresh from your step 1 call.
|
|
45
|
+
|
|
46
|
+
## Where to run it
|
|
47
|
+
|
|
48
|
+
From your app's project folder, on a machine where your app runs or can reach the same session storage: the same
|
|
49
|
+
environment variables your app needs (`SHOPIFY_API_KEY`, `SHOPIFY_API_SECRET`, `SHOPIFY_APP_URL`, `SCOPES`, your
|
|
50
|
+
database address) and after `npm install`. A `.env` file in the folder is read for any variable that is not already set.
|
|
51
|
+
|
|
52
|
+
Your `shopify.server` file must export `unauthenticated` and `sessionStorage`, as the template does:
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
export const unauthenticated = shopify.unauthenticated;
|
|
56
|
+
export const sessionStorage = shopify.sessionStorage;
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Options
|
|
60
|
+
|
|
61
|
+
| Option | |
|
|
62
|
+
|---|---|
|
|
63
|
+
| `--key=<key>` | Your app's Prys key. Or set `PRYS_KEY` (keeps it out of your shell history). |
|
|
64
|
+
| `--base-url=<url>` | Prys API address. Default `https://admin.prys.io/api/v1`. Plain `http://` only for localhost. |
|
|
65
|
+
| `--config=<path>` | Your `shopifyApp()` file, if it is not `./app/shopify.server.{ts,js}`. |
|
|
66
|
+
| `--concurrency=<n>` | Stores read at once, 1 to 20 (default 4). Each store has its own Shopify limit. |
|
|
67
|
+
| `--help`, `--version` | |
|
|
68
|
+
|
|
69
|
+
Prys allows 600 calls a minute per key; when it answers `rate_limited` the CLI waits as told and sends the same batch
|
|
70
|
+
again. The key is never printed.
|
|
71
|
+
|
|
72
|
+
## Other frameworks
|
|
73
|
+
|
|
74
|
+
Node / Express, Laravel, Rails and other backends: Prys > Customer CRM > Enrichment > step 2 shows a short script
|
|
75
|
+
for each, using the same two calls (`GET /installs`, `POST /identify/bulk`).
|
|
76
|
+
|
|
77
|
+
## Requirements
|
|
78
|
+
|
|
79
|
+
Node.js 18.18 or newer. TypeScript config files are loaded with [tsx](https://tsx.is) (installed with this package).
|
|
80
|
+
|
|
81
|
+
## Development
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
npm install
|
|
85
|
+
npm test
|
|
86
|
+
npm run check-query -- <front-end-crm>/app/src/sections/Dashboards/CustomerCrm/Enrichment/snippetTemplates.ts
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
`npm test` runs the CLI against a stub Prys server and a fake Shopify app (TypeScript and JavaScript
|
|
90
|
+
`shopify.server`). `check-query` fails when the shop query here and the CRM screen's step 1 query drift apart.
|
|
91
|
+
|
|
92
|
+
## License
|
|
93
|
+
|
|
94
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@prys/seed",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Backfill Prys Customer CRM: reads your installed stores' shop details with your Shopify app's own client and sends them to Prys.",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"prys",
|
|
7
|
-
"shopify",
|
|
8
|
-
"shopify-app",
|
|
9
|
-
"crm",
|
|
10
|
-
"backfill"
|
|
11
|
-
],
|
|
12
|
-
"homepage": "https://prys.io",
|
|
13
|
-
"license": "MIT",
|
|
14
|
-
"author": "Prys <connect@prys.io>",
|
|
15
|
-
"type": "module",
|
|
16
|
-
"bin": {
|
|
17
|
-
"prys-seed": "bin/prys-seed.js"
|
|
18
|
-
},
|
|
19
|
-
"files": [
|
|
20
|
-
"bin/",
|
|
21
|
-
"src/",
|
|
22
|
-
"README.md",
|
|
23
|
-
"LICENSE"
|
|
24
|
-
],
|
|
25
|
-
"engines": {
|
|
26
|
-
"node": ">=18.18"
|
|
27
|
-
},
|
|
28
|
-
"scripts": {
|
|
29
|
-
"test": "node --test test/*.test.js",
|
|
30
|
-
"check-query": "node scripts/check-query.js"
|
|
31
|
-
},
|
|
32
|
-
"dependencies": {
|
|
33
|
-
"tsx": "^4.20.0"
|
|
34
|
-
},
|
|
35
|
-
"publishConfig": {
|
|
36
|
-
"access": "public"
|
|
37
|
-
}
|
|
38
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@prys/seed",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Backfill Prys Customer CRM: reads your installed stores' shop details with your Shopify app's own client and sends them to Prys.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"prys",
|
|
7
|
+
"shopify",
|
|
8
|
+
"shopify-app",
|
|
9
|
+
"crm",
|
|
10
|
+
"backfill"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://prys.io",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": "Prys <connect@prys.io>",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"bin": {
|
|
17
|
+
"prys-seed": "bin/prys-seed.js"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"bin/",
|
|
21
|
+
"src/",
|
|
22
|
+
"README.md",
|
|
23
|
+
"LICENSE"
|
|
24
|
+
],
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=18.18"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"test": "node --test test/*.test.js",
|
|
30
|
+
"check-query": "node scripts/check-query.js"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"tsx": "^4.20.0"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
}
|
|
38
|
+
}
|