@zappie/sdk 0.2.1 → 0.4.0
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/CHANGELOG.md +12 -0
- package/dist/debug.js +1 -1
- package/dist/index.js +1 -1
- package/dist/services/index.d.ts +23 -0
- package/dist/services/index.js +26 -0
- package/dist/services/index.js.map +6 -0
- package/package.json +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @zappie/sdk
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- b884697: `zappieSupportUrl(context)` in `@zappie/foundations` builds a WhatsApp link to Zappie support for a shopper with a problem such as a payment. Its message starts with "Hi Zappie support," and names the store, the branch when the store has more than one, the order and the page, as the classic storefront does. `ZAPPIE_SUPPORT_WHATSAPP` in `@zappie/sdk/services` is the number it opens.
|
|
8
|
+
|
|
9
|
+
## 0.3.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- e0b5464: `checkoutUrl(path, environment)` and `appUrl(path, environment)` in the new `@zappie/sdk/services` entry build a URL on Zappie's checkout or app, for production or staging, such as the new home of an old payment or pay-point link. A path that could leave that service throws. `no-offsite-navigation` accepts both, as it accepts `safeRedirect`, and `no-direct-api` points a written-out checkout address to `checkoutUrl`.
|
|
14
|
+
|
|
3
15
|
## 0.2.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/debug.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { ZappieError, isZappieError } from "./errors.js";
|
|
|
10
10
|
export * from "./models.js";
|
|
11
11
|
import { format, money } from "./money.js";
|
|
12
12
|
import { RestTransport } from "./transport/rest.js";
|
|
13
|
-
var VERSION = true ? "0.
|
|
13
|
+
var VERSION = true ? "0.4.0" : "0.0.0-development";
|
|
14
14
|
export {
|
|
15
15
|
API_VERSION,
|
|
16
16
|
RestTransport,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** The Zappie environment a service URL points at. */
|
|
2
|
+
type ZappieEnvironment = "production" | "staging";
|
|
3
|
+
/**
|
|
4
|
+
* Build a URL on Zappie's checkout, such as an old payment link's new home.
|
|
5
|
+
*
|
|
6
|
+
* @param path - The checkout path, starting with one slash, such as `/pay/cs_123`.
|
|
7
|
+
* @param environment - `staging` for a test host. Defaults to `production`.
|
|
8
|
+
* @returns The absolute checkout URL. A path that could leave checkout throws a TypeError.
|
|
9
|
+
*/
|
|
10
|
+
declare const checkoutUrl: (path: string, environment?: ZappieEnvironment) => string;
|
|
11
|
+
/**
|
|
12
|
+
* Build a URL on the Zappie app, which serves in-venue pages such as pay points and reservations.
|
|
13
|
+
*
|
|
14
|
+
* @param path - The app path, starting with one slash, such as `/pay-point/pp1`.
|
|
15
|
+
* @param environment - `staging` for a test host. Defaults to `production`.
|
|
16
|
+
* @returns The absolute app URL. A path that could leave the app throws a TypeError.
|
|
17
|
+
*/
|
|
18
|
+
declare const appUrl: (path: string, environment?: ZappieEnvironment) => string;
|
|
19
|
+
/** Zappie's support WhatsApp number, the same one the classic storefront opens. */
|
|
20
|
+
declare const ZAPPIE_SUPPORT_WHATSAPP = "15558956471";
|
|
21
|
+
|
|
22
|
+
export { ZAPPIE_SUPPORT_WHATSAPP, appUrl, checkoutUrl };
|
|
23
|
+
export type { ZappieEnvironment };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// src/services/index.ts
|
|
2
|
+
var ORIGINS = {
|
|
3
|
+
checkout: {
|
|
4
|
+
production: "https://checkout.zappie.ai",
|
|
5
|
+
staging: "https://checkout.stg.zappie.ai"
|
|
6
|
+
},
|
|
7
|
+
app: {
|
|
8
|
+
production: "https://app.zappie.ai",
|
|
9
|
+
staging: "https://app.stg.zappie.ai"
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
var serviceUrl = (service, path, environment) => {
|
|
13
|
+
if (environment !== "production" && environment !== "staging" || !/^\/(?!\/)[^\u0000- \u007f\\]*$/u.test(path)) {
|
|
14
|
+
throw new TypeError("Pass a path that starts with one slash");
|
|
15
|
+
}
|
|
16
|
+
return ORIGINS[service][environment] + path;
|
|
17
|
+
};
|
|
18
|
+
var checkoutUrl = (path, environment = "production") => serviceUrl("checkout", path, environment);
|
|
19
|
+
var appUrl = (path, environment = "production") => serviceUrl("app", path, environment);
|
|
20
|
+
var ZAPPIE_SUPPORT_WHATSAPP = "15558956471";
|
|
21
|
+
export {
|
|
22
|
+
ZAPPIE_SUPPORT_WHATSAPP,
|
|
23
|
+
appUrl,
|
|
24
|
+
checkoutUrl
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/services/index.ts"],
|
|
4
|
+
"mappings": ";AAIA,IAAM,UAAU;AAAA,EACd,UAAU;AAAA,IACR,YAAY;AAAA,IACZ,SAAS;AAAA,EACX;AAAA,EACA,KAAK;AAAA,IACH,YAAY;AAAA,IACZ,SAAS;AAAA,EACX;AACF;AAGA,IAAM,aAAa,CACjB,SACA,MACA,gBACW;AACX,MACG,gBAAgB,gBAAgB,gBAAgB,aACjD,CAAC,kCAAkC,KAAK,IAAI,GAC5C;AACA,UAAM,IAAI,UAAU,wCAAwC;AAAA,EAC9D;AACA,SAAO,QAAQ,OAAO,EAAE,WAAW,IAAI;AACzC;AASO,IAAM,cAAc,CACzB,MACA,cAAiC,iBACtB,WAAW,YAAY,MAAM,WAAW;AAS9C,IAAM,SAAS,CACpB,MACA,cAAiC,iBACtB,WAAW,OAAO,MAAM,WAAW;AAGzC,IAAM,0BAA0B;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zappie/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Typed, framework-agnostic client for Zappie menus, carts, checkout, auth and events.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -33,6 +33,10 @@
|
|
|
33
33
|
"types": "./dist/redirect/index.d.ts",
|
|
34
34
|
"import": "./dist/redirect/index.js"
|
|
35
35
|
},
|
|
36
|
+
"./services": {
|
|
37
|
+
"types": "./dist/services/index.d.ts",
|
|
38
|
+
"import": "./dist/services/index.js"
|
|
39
|
+
},
|
|
36
40
|
"./testing": {
|
|
37
41
|
"types": "./dist/testing/index.d.ts",
|
|
38
42
|
"import": "./dist/testing/index.js"
|
|
@@ -144,7 +148,7 @@
|
|
|
144
148
|
"vite": "8.3.5"
|
|
145
149
|
},
|
|
146
150
|
"scripts": {
|
|
147
|
-
"build": "tsup && tsup --config tsup.checkout.config.ts && tsup --config tsup.checkout-defaults.config.ts && tsup --config tsup.customer.config.ts && tsup --config tsup.places.config.ts && tsup --config tsup.url.config.ts && tsup --config tsup.redirect.config.ts && tsup --config tsup.visits.config.ts && tsup --config tsup.pricing.config.ts && tsup --config tsup.site-config.config.ts && tsup --config tsup.template.config.ts && node ../../scripts/release-packages/build-modules.mjs --no-sources-content --unmapped=studio/index.js --unmapped=testing/index.js --unmapped=vite/index.js",
|
|
151
|
+
"build": "tsup && tsup --config tsup.checkout.config.ts && tsup --config tsup.checkout-defaults.config.ts && tsup --config tsup.customer.config.ts && tsup --config tsup.places.config.ts && tsup --config tsup.url.config.ts && tsup --config tsup.redirect.config.ts && tsup --config tsup.services.config.ts && tsup --config tsup.visits.config.ts && tsup --config tsup.pricing.config.ts && tsup --config tsup.site-config.config.ts && tsup --config tsup.template.config.ts && node ../../scripts/release-packages/build-modules.mjs --no-sources-content --unmapped=studio/index.js --unmapped=testing/index.js --unmapped=vite/index.js",
|
|
148
152
|
"test": "vitest run --root ../.. packages/sdk/test",
|
|
149
153
|
"size": "node ../../scripts/release-packages/size-sdk.mjs && size-limit"
|
|
150
154
|
}
|