feeef 0.12.0 → 0.12.2

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 CHANGED
@@ -2,6 +2,19 @@
2
2
 
3
3
  `feeefjs` is a TypeScript library for managing feeef e-commerce platforms for self-hosted stores. It provides a wrapper for feeef rest api such like send order..., also have frontend srvices like the `CartService` class for managing cart items, shipping methods, and calculating totals. The library also includes a `NotifiableService` base class for handling listeners that react to changes in the service state.
4
4
 
5
+ ## Publish to npm
6
+
7
+ Non-interactive publish (no login / OTP each time): see **[PUBLISH.md](./PUBLISH.md)**.
8
+
9
+ ```bash
10
+ # one-time: granular token + Bypass 2FA → ~/.config/feeef/npm_token or NPM_TOKEN
11
+ npm run publish:npm
12
+ # or version bump + tag + publish:
13
+ npm run release
14
+ ```
15
+
16
+ Related CLI package (separate publish): [`@feeef.dev/cli`](https://www.npmjs.com/package/@feeef.dev/cli) in monorepo `cli/`.
17
+
5
18
  ## Delivery parcel types
6
19
 
7
20
  Canonical shipment shapes mirror the API domain in `feeefapps/backend/services/delivery/domain/parcel.ts`. In this package they live under `src/delivery/parcel.ts` and are exported from the main entry (`ParcelCreate`, `ParcelUpdate`, `DeliveryCarrierClient`, …). Keep them in sync when the backend parcel model changes; published npm `feeef` should re-export the same definitions after each release.
package/build/index.js CHANGED
@@ -141,7 +141,8 @@ var ModelRepository = class {
141
141
  * @returns A promise that resolves to the created model.
142
142
  */
143
143
  async create(dataOrOptions, params) {
144
- if (dataOrOptions && typeof dataOrOptions === "object" && "data" in dataOrOptions) {
144
+ const looksLikeOptions = dataOrOptions && typeof dataOrOptions === "object" && "data" in dataOrOptions && Object.keys(dataOrOptions).every((k) => k === "data" || k === "params");
145
+ if (looksLikeOptions) {
145
146
  const options2 = dataOrOptions;
146
147
  const { data, params: optionsParams } = options2;
147
148
  const requestParams = optionsParams || params;
@@ -690,6 +691,29 @@ var StoreRepository = class extends ModelRepository {
690
691
  });
691
692
  return res.data;
692
693
  }
694
+ /**
695
+ * Upserts a draft theme preview (does not change live `metadata.templateData`).
696
+ */
697
+ async putTemplatePreview(storeId, body) {
698
+ const res = await this.client.put(`/${this.resource}/${storeId}/template-preview`, body);
699
+ return res.data;
700
+ }
701
+ /**
702
+ * Clears the draft theme preview for a store.
703
+ */
704
+ async clearTemplatePreview(storeId) {
705
+ const res = await this.client.delete(`/${this.resource}/${storeId}/template-preview`);
706
+ return res.data;
707
+ }
708
+ /**
709
+ * Fetches draft TemplateData with a signed preview token (public, token-gated).
710
+ */
711
+ async getTemplatePreview(storeId, token) {
712
+ const res = await this.client.get(`/${this.resource}/${storeId}/template-preview`, {
713
+ params: { token }
714
+ });
715
+ return res.data;
716
+ }
693
717
  };
694
718
 
695
719
  // src/feeef/repositories/users.ts
@@ -1168,15 +1192,18 @@ var OAuthRepository = class {
1168
1192
  }
1169
1193
  /**
1170
1194
  * Exchanges an authorization code for an access token.
1195
+ * Public clients omit `clientSecret` and must send `codeVerifier` (PKCE).
1171
1196
  */
1172
1197
  async exchangeAuthorizationCode(params) {
1173
1198
  const body = new URLSearchParams({
1174
1199
  grant_type: "authorization_code",
1175
1200
  code: params.code,
1176
1201
  redirect_uri: params.redirectUri,
1177
- client_id: params.clientId,
1178
- client_secret: params.clientSecret
1202
+ client_id: params.clientId
1179
1203
  });
1204
+ if (params.clientSecret) {
1205
+ body.set("client_secret", params.clientSecret);
1206
+ }
1180
1207
  if (params.codeVerifier) {
1181
1208
  body.set("code_verifier", params.codeVerifier);
1182
1209
  }
@@ -2947,16 +2974,41 @@ var StoreTemplatesRepository = class extends ModelRepository {
2947
2974
  return res.data;
2948
2975
  }
2949
2976
  /**
2950
- * Set `stores.template_id` to this template (same row in `store_templates`)
2951
- * and copy `data` into `store.metadata.templateData`. Does not create a new
2952
- * `store_templates` row — use [fork] to duplicate a template into a store.
2977
+ * Set `stores.template_id` (+ optional release pin) and copy release/listing
2978
+ * `data` into `store.metadata.templateData`. Paid listings require a license.
2953
2979
  */
2954
2980
  async install(options) {
2955
2981
  const res = await this.client.post(`/${this.resource}/${options.fromId}/install`, {
2982
+ storeId: options.storeId,
2983
+ ...options.releaseId ? { releaseId: options.releaseId } : {}
2984
+ });
2985
+ return res.data;
2986
+ }
2987
+ /** One-time wallet purchase → forever store license. */
2988
+ async purchase(options) {
2989
+ const res = await this.client.post(`/${this.resource}/${options.fromId}/purchase`, {
2956
2990
  storeId: options.storeId
2957
2991
  });
2958
2992
  return res.data;
2959
2993
  }
2994
+ /** List immutable releases (newest first). */
2995
+ async listReleases(templateId, options) {
2996
+ const res = await this.client.get(`/${this.resource}/${templateId}/releases`, {
2997
+ params: options?.storeId ? { storeId: options.storeId } : void 0
2998
+ });
2999
+ return res.data;
3000
+ }
3001
+ async getRelease(templateId, releaseId, options) {
3002
+ const res = await this.client.get(`/${this.resource}/${templateId}/releases/${releaseId}`, {
3003
+ params: options?.storeId ? { storeId: options.storeId } : void 0
3004
+ });
3005
+ return res.data;
3006
+ }
3007
+ /** Author publishes a new immutable release. */
3008
+ async createRelease(templateId, input) {
3009
+ const res = await this.client.post(`/${this.resource}/${templateId}/releases`, input);
3010
+ return res.data;
3011
+ }
2960
3012
  /** GET locales bundle (`defaultLocale`, `locales`, `messages`). */
2961
3013
  async listLocales(templateId) {
2962
3014
  const res = await this.client.get(`/${this.resource}/${templateId}/locales`);