@snowcone-app/sdk 0.18.0 → 0.19.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/{chunk-7DRH6S4D.js → chunk-ZJW7HA5R.js} +23 -19
- package/dist/index.cjs +30 -22
- package/dist/index.d.cts +21 -8
- package/dist/index.d.ts +21 -8
- package/dist/index.js +8 -4
- package/dist/server.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.19.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#887](https://github.com/snowcone-app/snowcone-monorepo/pull/887) [`e731ea4`](https://github.com/snowcone-app/snowcone-monorepo/commit/e731ea4fb0c8f2c642c8d6e06bc3015f00391a30) Thanks [@kevinsproles](https://github.com/kevinsproles)! - `getMockupUrl`/`getBuyUrl`: `asset` is now a base design that broadcasts to every product placement, and a new `placements` override map targets individual placements (ADR-0089). One image now appears on all placements by default; per-placement art is the advanced opt-in. The resolver-side broadcast is already live; this publishes the typed `placements` builder option to match.
|
|
8
|
+
|
|
9
|
+
## 0.18.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#857](https://github.com/snowcone-app/snowcone-monorepo/pull/857) [`723efd3`](https://github.com/snowcone-app/snowcone-monorepo/commit/723efd37a0c9c15589403748e339348e29e08147) Thanks [@kevinsproles](https://github.com/kevinsproles)! - Update the public catalog key value (the Meilisearch master key was rotated, which re-derives every API key's value). Same read-only `search` + `documents.get` scope as before.
|
|
14
|
+
|
|
3
15
|
## 0.18.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -147,28 +147,32 @@ function buildPublicMockupUrl(options, cfg = {}) {
|
|
|
147
147
|
const enc = encodeURIComponent;
|
|
148
148
|
const parts = [];
|
|
149
149
|
parts.push(`${PARAMS.shop}=${enc(options.shop)}`);
|
|
150
|
-
if (options.
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
if (
|
|
164
|
-
parts.push(`${PARAM_PREFIX.
|
|
150
|
+
if (options.designRef !== void 0) {
|
|
151
|
+
parts.push(`${PARAMS.design}=${enc(options.designRef)}`);
|
|
152
|
+
} else {
|
|
153
|
+
if (options.assetUrl !== void 0) {
|
|
154
|
+
parts.push(`${PARAMS.asset}=${enc(options.assetUrl)}`);
|
|
155
|
+
}
|
|
156
|
+
const overrides = options.design || options.placements ? { ...options.design ?? {}, ...options.placements ?? {} } : void 0;
|
|
157
|
+
if (overrides) {
|
|
158
|
+
for (const key of Object.keys(overrides).sort()) {
|
|
159
|
+
const fill = overrides[key];
|
|
160
|
+
const k = enc(key);
|
|
161
|
+
if (typeof fill === "string") {
|
|
162
|
+
parts.push(`${PARAM_PREFIX.asset}${k}=${enc(fill)}`);
|
|
163
|
+
} else if ("color" in fill) {
|
|
164
|
+
parts.push(`${PARAM_PREFIX.color}${k}=${enc(fill.color)}`);
|
|
165
|
+
} else {
|
|
166
|
+
parts.push(`${PARAM_PREFIX.asset}${k}=${enc(fill.src)}`);
|
|
167
|
+
if (fill.tile !== void 0) {
|
|
168
|
+
parts.push(`${PARAM_PREFIX.tile}${k}=${fill.tile}`);
|
|
169
|
+
}
|
|
170
|
+
if (fill.align !== void 0) {
|
|
171
|
+
parts.push(`${PARAM_PREFIX.align}${k}=${enc(fill.align)}`);
|
|
172
|
+
}
|
|
165
173
|
}
|
|
166
174
|
}
|
|
167
175
|
}
|
|
168
|
-
} else if (options.assetUrl !== void 0) {
|
|
169
|
-
parts.push(`${PARAMS.asset}=${enc(options.assetUrl)}`);
|
|
170
|
-
} else if (options.designRef !== void 0) {
|
|
171
|
-
parts.push(`${PARAMS.design}=${enc(options.designRef)}`);
|
|
172
176
|
}
|
|
173
177
|
if (options.placement !== void 0) {
|
|
174
178
|
parts.push(`${PARAMS.placement}=${enc(options.placement)}`);
|
package/dist/index.cjs
CHANGED
|
@@ -626,28 +626,32 @@ function buildPublicMockupUrl(options, cfg = {}) {
|
|
|
626
626
|
const enc = encodeURIComponent;
|
|
627
627
|
const parts = [];
|
|
628
628
|
parts.push(`${PARAMS.shop}=${enc(options.shop)}`);
|
|
629
|
-
if (options.
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
if (
|
|
643
|
-
parts.push(`${PARAM_PREFIX.
|
|
629
|
+
if (options.designRef !== void 0) {
|
|
630
|
+
parts.push(`${PARAMS.design}=${enc(options.designRef)}`);
|
|
631
|
+
} else {
|
|
632
|
+
if (options.assetUrl !== void 0) {
|
|
633
|
+
parts.push(`${PARAMS.asset}=${enc(options.assetUrl)}`);
|
|
634
|
+
}
|
|
635
|
+
const overrides = options.design || options.placements ? { ...options.design ?? {}, ...options.placements ?? {} } : void 0;
|
|
636
|
+
if (overrides) {
|
|
637
|
+
for (const key of Object.keys(overrides).sort()) {
|
|
638
|
+
const fill = overrides[key];
|
|
639
|
+
const k = enc(key);
|
|
640
|
+
if (typeof fill === "string") {
|
|
641
|
+
parts.push(`${PARAM_PREFIX.asset}${k}=${enc(fill)}`);
|
|
642
|
+
} else if ("color" in fill) {
|
|
643
|
+
parts.push(`${PARAM_PREFIX.color}${k}=${enc(fill.color)}`);
|
|
644
|
+
} else {
|
|
645
|
+
parts.push(`${PARAM_PREFIX.asset}${k}=${enc(fill.src)}`);
|
|
646
|
+
if (fill.tile !== void 0) {
|
|
647
|
+
parts.push(`${PARAM_PREFIX.tile}${k}=${fill.tile}`);
|
|
648
|
+
}
|
|
649
|
+
if (fill.align !== void 0) {
|
|
650
|
+
parts.push(`${PARAM_PREFIX.align}${k}=${enc(fill.align)}`);
|
|
651
|
+
}
|
|
644
652
|
}
|
|
645
653
|
}
|
|
646
654
|
}
|
|
647
|
-
} else if (options.assetUrl !== void 0) {
|
|
648
|
-
parts.push(`${PARAMS.asset}=${enc(options.assetUrl)}`);
|
|
649
|
-
} else if (options.designRef !== void 0) {
|
|
650
|
-
parts.push(`${PARAMS.design}=${enc(options.designRef)}`);
|
|
651
655
|
}
|
|
652
656
|
if (options.placement !== void 0) {
|
|
653
657
|
parts.push(`${PARAMS.placement}=${enc(options.placement)}`);
|
|
@@ -946,7 +950,11 @@ function getMockupUrl(a, b, c) {
|
|
|
946
950
|
{
|
|
947
951
|
productCode,
|
|
948
952
|
shop: opts.shop,
|
|
953
|
+
// ADR-0089 base+override: the `asset` base and the `design`/`placements`
|
|
954
|
+
// override map COMPOSE (the builder merges them). `placements` is the
|
|
955
|
+
// preferred override name; `design` is the legacy alias.
|
|
949
956
|
...opts.design ? { design: opts.design } : {},
|
|
957
|
+
...opts.placements ? { placements: opts.placements } : {},
|
|
950
958
|
...assetUrl !== void 0 ? { assetUrl } : {},
|
|
951
959
|
...opts.designRef !== void 0 ? { designRef: opts.designRef } : {},
|
|
952
960
|
...opts.options ? { options: opts.options } : {},
|
|
@@ -6205,7 +6213,7 @@ function validateProductLoose(product) {
|
|
|
6205
6213
|
async function listProducts(config) {
|
|
6206
6214
|
const f = getFetcher(config);
|
|
6207
6215
|
const meilisearchHost = config?.meilisearch?.host || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_HOST || "https://search.snowcone.app";
|
|
6208
|
-
const meilisearchApiKey = config?.meilisearch?.apiKey || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_API_KEY || "
|
|
6216
|
+
const meilisearchApiKey = config?.meilisearch?.apiKey || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_API_KEY || "73f573ead9be75531c56ee89d104caa49d79154db387f119a013d33eccfe654b";
|
|
6209
6217
|
const meilisearchIndex = config?.meilisearch?.index || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_INDEX || "snowcone";
|
|
6210
6218
|
const headers = {
|
|
6211
6219
|
"Content-Type": "application/json"
|
|
@@ -6231,7 +6239,7 @@ async function listProducts(config) {
|
|
|
6231
6239
|
async function getProduct(idOrSlug, config) {
|
|
6232
6240
|
const f = getFetcher(config);
|
|
6233
6241
|
const meilisearchHost = config?.meilisearch?.host || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_HOST || "https://search.snowcone.app";
|
|
6234
|
-
const meilisearchApiKey = config?.meilisearch?.apiKey || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_API_KEY || "
|
|
6242
|
+
const meilisearchApiKey = config?.meilisearch?.apiKey || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_API_KEY || "73f573ead9be75531c56ee89d104caa49d79154db387f119a013d33eccfe654b";
|
|
6235
6243
|
const meilisearchIndex = config?.meilisearch?.index || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_INDEX || "snowcone";
|
|
6236
6244
|
const headers = {
|
|
6237
6245
|
"Content-Type": "application/json"
|
|
@@ -6255,7 +6263,7 @@ async function getProduct(idOrSlug, config) {
|
|
|
6255
6263
|
async function searchDesigns(query = "", options) {
|
|
6256
6264
|
const f = getFetcher(options);
|
|
6257
6265
|
const meilisearchHost = options?.meilisearch?.host || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_HOST || "https://search.snowcone.app";
|
|
6258
|
-
const meilisearchApiKey = options?.meilisearch?.apiKey || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_API_KEY || "
|
|
6266
|
+
const meilisearchApiKey = options?.meilisearch?.apiKey || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_API_KEY || "73f573ead9be75531c56ee89d104caa49d79154db387f119a013d33eccfe654b";
|
|
6259
6267
|
const designsIndex = options?.meilisearch?.designsIndex || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_DESIGNS_INDEX || "snowcone-designs";
|
|
6260
6268
|
const headers = {
|
|
6261
6269
|
"Content-Type": "application/json"
|
package/dist/index.d.cts
CHANGED
|
@@ -225,9 +225,11 @@ type Design = PublicDesign;
|
|
|
225
225
|
/**
|
|
226
226
|
* Options for the code-first {@link getMockupUrl} form.
|
|
227
227
|
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
228
|
+
* Artwork follows the ADR-0089 base+override model: `asset` is the BASE every
|
|
229
|
+
* placement inherits, and `placements` (or its `design` alias) is a per-key
|
|
230
|
+
* OVERRIDE map. They COMPOSE — give just `asset` to broadcast one image
|
|
231
|
+
* everywhere, add `placements` to retarget specific placements, or give only
|
|
232
|
+
* `placements` to fill named placements and leave the rest blank.
|
|
231
233
|
*/
|
|
232
234
|
interface GetMockupUrlOptions {
|
|
233
235
|
/**
|
|
@@ -237,17 +239,28 @@ interface GetMockupUrlOptions {
|
|
|
237
239
|
*/
|
|
238
240
|
shop: string;
|
|
239
241
|
/**
|
|
240
|
-
*
|
|
241
|
-
* readable `asset=` param
|
|
242
|
-
*
|
|
242
|
+
* The BASE design — one image every placement inherits (ADR-0089). Emitted as
|
|
243
|
+
* the readable `asset=` param; the resolver broadcasts it across every
|
|
244
|
+
* placement. Composes with {@link GetMockupUrlOptions.placements} /
|
|
245
|
+
* {@link GetMockupUrlOptions.design} overrides (it is no longer ignored when
|
|
246
|
+
* those are present). `asset=default` is the reserved house-blank token.
|
|
243
247
|
*/
|
|
244
248
|
asset?: string;
|
|
245
249
|
/**
|
|
246
|
-
*
|
|
250
|
+
* Per-placement OVERRIDES: a map of placement key → {@link Fill}. Emitted as
|
|
247
251
|
* the dotted `asset.<key>` / `color.<key>` / `tile.<key>` / `align.<key>`
|
|
248
|
-
* params.
|
|
252
|
+
* params. Composes WITH `asset` (ADR-0089): the `asset` base seeds every
|
|
253
|
+
* placement; each entry here overrides that one placement. `placements` is the
|
|
254
|
+
* preferred name; `design` is the legacy alias (both merge, override wins).
|
|
249
255
|
*/
|
|
250
256
|
design?: Design;
|
|
257
|
+
/**
|
|
258
|
+
* Per-placement overrides — the named, ADR-0089 form of {@link
|
|
259
|
+
* GetMockupUrlOptions.design}. A map of placement key → {@link Fill} that
|
|
260
|
+
* overrides the `asset` base on just those placements; unlisted placements
|
|
261
|
+
* keep the base. Merges with `design` if both are supplied.
|
|
262
|
+
*/
|
|
263
|
+
placements?: Design;
|
|
251
264
|
/**
|
|
252
265
|
* Catalog design reference (ADR-0086): a `pairingId` or `slug` from the
|
|
253
266
|
* public designs catalog (`searchDesigns`). Emitted as `design=` — the
|
package/dist/index.d.ts
CHANGED
|
@@ -225,9 +225,11 @@ type Design = PublicDesign;
|
|
|
225
225
|
/**
|
|
226
226
|
* Options for the code-first {@link getMockupUrl} form.
|
|
227
227
|
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
228
|
+
* Artwork follows the ADR-0089 base+override model: `asset` is the BASE every
|
|
229
|
+
* placement inherits, and `placements` (or its `design` alias) is a per-key
|
|
230
|
+
* OVERRIDE map. They COMPOSE — give just `asset` to broadcast one image
|
|
231
|
+
* everywhere, add `placements` to retarget specific placements, or give only
|
|
232
|
+
* `placements` to fill named placements and leave the rest blank.
|
|
231
233
|
*/
|
|
232
234
|
interface GetMockupUrlOptions {
|
|
233
235
|
/**
|
|
@@ -237,17 +239,28 @@ interface GetMockupUrlOptions {
|
|
|
237
239
|
*/
|
|
238
240
|
shop: string;
|
|
239
241
|
/**
|
|
240
|
-
*
|
|
241
|
-
* readable `asset=` param
|
|
242
|
-
*
|
|
242
|
+
* The BASE design — one image every placement inherits (ADR-0089). Emitted as
|
|
243
|
+
* the readable `asset=` param; the resolver broadcasts it across every
|
|
244
|
+
* placement. Composes with {@link GetMockupUrlOptions.placements} /
|
|
245
|
+
* {@link GetMockupUrlOptions.design} overrides (it is no longer ignored when
|
|
246
|
+
* those are present). `asset=default` is the reserved house-blank token.
|
|
243
247
|
*/
|
|
244
248
|
asset?: string;
|
|
245
249
|
/**
|
|
246
|
-
*
|
|
250
|
+
* Per-placement OVERRIDES: a map of placement key → {@link Fill}. Emitted as
|
|
247
251
|
* the dotted `asset.<key>` / `color.<key>` / `tile.<key>` / `align.<key>`
|
|
248
|
-
* params.
|
|
252
|
+
* params. Composes WITH `asset` (ADR-0089): the `asset` base seeds every
|
|
253
|
+
* placement; each entry here overrides that one placement. `placements` is the
|
|
254
|
+
* preferred name; `design` is the legacy alias (both merge, override wins).
|
|
249
255
|
*/
|
|
250
256
|
design?: Design;
|
|
257
|
+
/**
|
|
258
|
+
* Per-placement overrides — the named, ADR-0089 form of {@link
|
|
259
|
+
* GetMockupUrlOptions.design}. A map of placement key → {@link Fill} that
|
|
260
|
+
* overrides the `asset` base on just those placements; unlisted placements
|
|
261
|
+
* keep the base. Merges with `design` if both are supplied.
|
|
262
|
+
*/
|
|
263
|
+
placements?: Design;
|
|
251
264
|
/**
|
|
252
265
|
* Catalog design reference (ADR-0086): a `pairingId` or `slug` from the
|
|
253
266
|
* public designs catalog (`searchDesigns`). Emitted as `design=` — the
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
canonicalForSig,
|
|
12
12
|
normalizeDesignElements,
|
|
13
13
|
normalizeWidth
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-ZJW7HA5R.js";
|
|
15
15
|
|
|
16
16
|
// src/validation.ts
|
|
17
17
|
import { z } from "zod";
|
|
@@ -550,7 +550,11 @@ function getMockupUrl(a, b, c) {
|
|
|
550
550
|
{
|
|
551
551
|
productCode,
|
|
552
552
|
shop: opts.shop,
|
|
553
|
+
// ADR-0089 base+override: the `asset` base and the `design`/`placements`
|
|
554
|
+
// override map COMPOSE (the builder merges them). `placements` is the
|
|
555
|
+
// preferred override name; `design` is the legacy alias.
|
|
553
556
|
...opts.design ? { design: opts.design } : {},
|
|
557
|
+
...opts.placements ? { placements: opts.placements } : {},
|
|
554
558
|
...assetUrl !== void 0 ? { assetUrl } : {},
|
|
555
559
|
...opts.designRef !== void 0 ? { designRef: opts.designRef } : {},
|
|
556
560
|
...opts.options ? { options: opts.options } : {},
|
|
@@ -5039,7 +5043,7 @@ function validateProductLoose(product) {
|
|
|
5039
5043
|
async function listProducts(config) {
|
|
5040
5044
|
const f = getFetcher(config);
|
|
5041
5045
|
const meilisearchHost = config?.meilisearch?.host || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_HOST || "https://search.snowcone.app";
|
|
5042
|
-
const meilisearchApiKey = config?.meilisearch?.apiKey || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_API_KEY || "
|
|
5046
|
+
const meilisearchApiKey = config?.meilisearch?.apiKey || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_API_KEY || "73f573ead9be75531c56ee89d104caa49d79154db387f119a013d33eccfe654b";
|
|
5043
5047
|
const meilisearchIndex = config?.meilisearch?.index || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_INDEX || "snowcone";
|
|
5044
5048
|
const headers = {
|
|
5045
5049
|
"Content-Type": "application/json"
|
|
@@ -5065,7 +5069,7 @@ async function listProducts(config) {
|
|
|
5065
5069
|
async function getProduct(idOrSlug, config) {
|
|
5066
5070
|
const f = getFetcher(config);
|
|
5067
5071
|
const meilisearchHost = config?.meilisearch?.host || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_HOST || "https://search.snowcone.app";
|
|
5068
|
-
const meilisearchApiKey = config?.meilisearch?.apiKey || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_API_KEY || "
|
|
5072
|
+
const meilisearchApiKey = config?.meilisearch?.apiKey || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_API_KEY || "73f573ead9be75531c56ee89d104caa49d79154db387f119a013d33eccfe654b";
|
|
5069
5073
|
const meilisearchIndex = config?.meilisearch?.index || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_INDEX || "snowcone";
|
|
5070
5074
|
const headers = {
|
|
5071
5075
|
"Content-Type": "application/json"
|
|
@@ -5089,7 +5093,7 @@ async function getProduct(idOrSlug, config) {
|
|
|
5089
5093
|
async function searchDesigns(query = "", options) {
|
|
5090
5094
|
const f = getFetcher(options);
|
|
5091
5095
|
const meilisearchHost = options?.meilisearch?.host || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_HOST || "https://search.snowcone.app";
|
|
5092
|
-
const meilisearchApiKey = options?.meilisearch?.apiKey || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_API_KEY || "
|
|
5096
|
+
const meilisearchApiKey = options?.meilisearch?.apiKey || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_API_KEY || "73f573ead9be75531c56ee89d104caa49d79154db387f119a013d33eccfe654b";
|
|
5093
5097
|
const designsIndex = options?.meilisearch?.designsIndex || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_DESIGNS_INDEX || "snowcone-designs";
|
|
5094
5098
|
const headers = {
|
|
5095
5099
|
"Content-Type": "application/json"
|
package/dist/server.js
CHANGED