@proveanything/smartlinks 2.1.24 → 2.1.27

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/dist/i18n.js ADDED
@@ -0,0 +1,298 @@
1
+ // src/i18n.ts
2
+ //
3
+ // An app's own words, in the person's language: buttons, labels, messages. (Translating CONTENT —
4
+ // product names, page text — is `translations.resolve`; this is the app's fixed strings.)
5
+ //
6
+ // How it fits together (prove docs/design/multi-language.md 8a):
7
+ // - The app keeps its English as keys in `public/i18n/en.json`, so the build ships it at
8
+ // `<bundle>/i18n/en.json`. That is the app's only translation job.
9
+ // - When the app is published, the platform translates the English into the admin languages it
10
+ // supports and adds `<bundle>/i18n/<lang>.json` (e.g. zh-Hans.json). An app may ship its own
11
+ // `<lang>.json` too: its keys win, the platform fills the gaps.
12
+ // - At run time the host says which language: `?lang=` (Studio passes the person's Studio
13
+ // language), later changes arrive live as `smartlinks:root-state` messages. A key missing in
14
+ // that language shows its English. Nothing ever shows a raw key unless English lacks it too.
15
+ //
16
+ // Framework-free. In React, re-render on a language change with useSyncExternalStore:
17
+ //
18
+ // import { i18n } from '@proveanything/smartlinks'
19
+ // await i18n.init() // once, before first render
20
+ // export function useT() {
21
+ // useSyncExternalStore(i18n.subscribe, i18n.snapshot)
22
+ // return i18n.t
23
+ // }
24
+ // const t = useT(); t('contacts.add') t('contacts.count', { count: 3 })
25
+ //
26
+ // Catalog format (the same shape i18next uses, so files move between tools):
27
+ // { "contacts": { "add": "Add contact", "count_one": "{{count}} contact", "count_other": "{{count}} contacts" } }
28
+ // Nested keys are read with dots. `{{name}}` is replaced from the values. With `count`, the plural
29
+ // form for the language is picked (`_one`, `_other`, …; Chinese has only `_other`).
30
+ import { readContext } from './context.js';
31
+ let source = 'en';
32
+ let current = 'en';
33
+ let base = null;
34
+ const loaded = new Map();
35
+ const supplied = new Map();
36
+ const listeners = new Set();
37
+ let version = 0;
38
+ let listening = false;
39
+ function emit() {
40
+ version++;
41
+ listeners.forEach((fn) => {
42
+ try {
43
+ fn();
44
+ }
45
+ catch ( /* a listener's own problem */_a) { /* a listener's own problem */ }
46
+ });
47
+ }
48
+ function bundleBase() {
49
+ if (base)
50
+ return base;
51
+ try {
52
+ // The page's own folder: an app served at .../apps/<id>/<channel>/admin.html#/... finds i18n/ beside it.
53
+ return new URL('i18n/', document.baseURI).toString();
54
+ }
55
+ catch (_a) {
56
+ return 'i18n/';
57
+ }
58
+ }
59
+ /** The language the host asked for, in a normal form ('zh-hans' -> 'zh-Hans', 'FR' -> 'fr'). */
60
+ export function normalizeLanguage(code) {
61
+ if (!code || typeof code !== 'string')
62
+ return null;
63
+ const m = /^([a-z]{2,3})(?:[-_]([a-z]{4}))?(?:[-_]([a-z]{2}|\d{3}))?$/i.exec(code.trim());
64
+ if (!m)
65
+ return null;
66
+ const [, lang, script, region] = m;
67
+ return [lang.toLowerCase(), script && script[0].toUpperCase() + script.slice(1).toLowerCase(), region && region.toUpperCase()]
68
+ .filter(Boolean)
69
+ .join('-');
70
+ }
71
+ /**
72
+ * The file a language is served as. Chinese is kept by script: zh-CN / zh-SG / bare zh read
73
+ * zh-Hans, zh-TW / zh-HK / zh-MO read zh-Hant. A region otherwise falls back to its language
74
+ * (fr-CA -> fr) when there is no file for the region.
75
+ */
76
+ function candidates(lang) {
77
+ const out = [lang];
78
+ const [l, second] = lang.split('-');
79
+ if (l === 'zh') {
80
+ const traditional = /^(Hant|TW|HK|MO)$/i.test(second || '');
81
+ out.push(traditional ? 'zh-Hant' : 'zh-Hans');
82
+ }
83
+ if (second && l !== 'zh')
84
+ out.push(l);
85
+ return Array.from(new Set(out));
86
+ }
87
+ /** Which language to start in: what the host passed, else the page's, else the browser's, else the source. */
88
+ export function detectLanguage() {
89
+ try {
90
+ const fromHost = normalizeLanguage(readContext().lang);
91
+ if (fromHost)
92
+ return fromHost;
93
+ const root = typeof document !== 'undefined' ? document.documentElement : undefined;
94
+ if (root && typeof root.getAttribute === 'function') {
95
+ const fromPage = normalizeLanguage(root.getAttribute('lang'));
96
+ if (fromPage)
97
+ return fromPage;
98
+ }
99
+ if (typeof navigator !== 'undefined') {
100
+ const fromBrowser = normalizeLanguage(navigator.language);
101
+ if (fromBrowser)
102
+ return fromBrowser;
103
+ }
104
+ }
105
+ catch ( /* not in a browser */_a) { /* not in a browser */ }
106
+ return source;
107
+ }
108
+ /** Mark the page with the language in use (screen readers, fonts), where there is a page. */
109
+ function setPageLanguage(lang) {
110
+ try {
111
+ const root = typeof document !== 'undefined' ? document.documentElement : undefined;
112
+ if (root && typeof root.setAttribute === 'function')
113
+ root.setAttribute('lang', lang);
114
+ }
115
+ catch ( /* not a browser page */_a) { /* not a browser page */ }
116
+ }
117
+ async function fetchCatalog(lang) {
118
+ if (supplied.has(lang))
119
+ return supplied.get(lang);
120
+ if (loaded.has(lang))
121
+ return loaded.get(lang);
122
+ for (const name of candidates(lang)) {
123
+ if (supplied.has(name))
124
+ return supplied.get(name);
125
+ try {
126
+ const res = await fetch(`${bundleBase()}${name}.json`, { cache: 'default' });
127
+ if (!res.ok)
128
+ continue;
129
+ const type = res.headers.get('content-type') || '';
130
+ // A host that answers every path with its index page isn't a catalog.
131
+ if (type && !type.includes('json'))
132
+ continue;
133
+ const data = (await res.json());
134
+ if (data && typeof data === 'object') {
135
+ loaded.set(lang, data);
136
+ return data;
137
+ }
138
+ }
139
+ catch ( /* not there, or offline: fall back */_a) { /* not there, or offline: fall back */ }
140
+ }
141
+ return null;
142
+ }
143
+ function listen() {
144
+ if (listening || typeof window === 'undefined')
145
+ return;
146
+ listening = true;
147
+ // The host says the language changed (Studio, the portal): same message theme-boot.js reads.
148
+ window.addEventListener('message', (e) => {
149
+ const d = e && e.data;
150
+ if (!d || typeof d !== 'object')
151
+ return;
152
+ if ((d.type === 'smartlinks:root-state' || d.type === 'smartlinks:language') && typeof d.lang === 'string') {
153
+ void setLanguage(d.lang);
154
+ }
155
+ });
156
+ }
157
+ /**
158
+ * Load the source catalog and the current language's. Call once before the first render; safe to
159
+ * call again. Never throws: with nothing found, `t` returns the keys' English or the keys.
160
+ */
161
+ export async function init(options = {}) {
162
+ source = normalizeLanguage(options.sourceLanguage) || 'en';
163
+ if (options.baseUrl)
164
+ base = options.baseUrl.endsWith('/') ? options.baseUrl : `${options.baseUrl}/`;
165
+ if (options.catalogs)
166
+ for (const [lang, cat] of Object.entries(options.catalogs)) {
167
+ const key = normalizeLanguage(lang) || lang;
168
+ supplied.set(key, cat);
169
+ }
170
+ current = normalizeLanguage(options.language) || detectLanguage();
171
+ listen();
172
+ await Promise.all([fetchCatalog(source), current === source ? null : fetchCatalog(current)]);
173
+ setPageLanguage(current);
174
+ emit();
175
+ }
176
+ /** Switch language (loads its catalog first, so the switch happens in one step). */
177
+ export async function setLanguage(lang) {
178
+ const next = normalizeLanguage(lang);
179
+ if (!next || next === current)
180
+ return;
181
+ await fetchCatalog(next);
182
+ current = next;
183
+ setPageLanguage(current);
184
+ emit();
185
+ }
186
+ /** The language in use. */
187
+ export function language() {
188
+ return current;
189
+ }
190
+ function lookup(cat, key) {
191
+ if (!cat)
192
+ return undefined;
193
+ if (typeof cat[key] === 'string')
194
+ return cat[key]; // flat keys with dots also work
195
+ let node = cat;
196
+ for (const part of key.split('.')) {
197
+ if (!node || typeof node !== 'object')
198
+ return undefined;
199
+ node = node[part];
200
+ }
201
+ return typeof node === 'string' ? node : undefined;
202
+ }
203
+ function pluralCategory(lang, count) {
204
+ try {
205
+ const PR = Intl.PluralRules;
206
+ if (PR)
207
+ return new PR(lang).select(count);
208
+ }
209
+ catch ( /* unknown locale */_a) { /* unknown locale */ }
210
+ return count === 1 ? 'one' : 'other';
211
+ }
212
+ /** The catalog for a language: supplied or fetched, trying its fallbacks (zh-CN -> zh-Hans, fr-CA -> fr). */
213
+ function catalogFor(lang) {
214
+ for (const name of candidates(lang)) {
215
+ const cat = supplied.get(name) || loaded.get(name);
216
+ if (cat)
217
+ return cat;
218
+ }
219
+ return loaded.get(lang);
220
+ }
221
+ function find(lang, key, count) {
222
+ var _a;
223
+ const cat = catalogFor(lang);
224
+ if (typeof count === 'number') {
225
+ const form = (_a = lookup(cat, `${key}_${pluralCategory(lang, count)}`)) !== null && _a !== void 0 ? _a : lookup(cat, `${key}_other`);
226
+ if (form !== undefined)
227
+ return form;
228
+ }
229
+ return lookup(cat, key);
230
+ }
231
+ /**
232
+ * Translate `key` into the current language, falling back to the source language, then to
233
+ * `values.defaultValue`, then to the key itself. `{{name}}` is filled from `values`; `count`
234
+ * picks the plural form.
235
+ */
236
+ export function t(key, values) {
237
+ var _a, _b, _c;
238
+ const count = values && typeof values.count === 'number' ? values.count : undefined;
239
+ const text = (_c = (_b = (_a = find(current, key, count)) !== null && _a !== void 0 ? _a : (current === source ? undefined : find(source, key, count))) !== null && _b !== void 0 ? _b : values === null || values === void 0 ? void 0 : values.defaultValue) !== null && _c !== void 0 ? _c : key;
240
+ if (!values)
241
+ return text;
242
+ return text.replace(/\{\{\s*([\w.]+)\s*\}\}/g, (m, name) => {
243
+ const v = values[name];
244
+ if (v === undefined || v === null)
245
+ return m;
246
+ return typeof v === 'number' ? v.toLocaleString(current) : String(v);
247
+ });
248
+ }
249
+ /** Is there a translation for `key` in the current language (not just the English fallback)? */
250
+ export function has(key) {
251
+ return find(current, key) !== undefined;
252
+ }
253
+ /** Subscribe to language/catalog changes. Returns an unsubscribe. (For React's useSyncExternalStore.) */
254
+ export function subscribe(fn) {
255
+ listeners.add(fn);
256
+ return () => { listeners.delete(fn); };
257
+ }
258
+ /** Changes on every language or catalog change. (The snapshot for useSyncExternalStore.) */
259
+ export function snapshot() {
260
+ return version;
261
+ }
262
+ /** Dates and numbers in the current language. */
263
+ export const format = {
264
+ number: (n, opts) => {
265
+ try {
266
+ return new Intl.NumberFormat(current, opts).format(n);
267
+ }
268
+ catch (_a) {
269
+ return String(n);
270
+ }
271
+ },
272
+ date: (d, opts) => {
273
+ try {
274
+ return new Intl.DateTimeFormat(current, opts !== null && opts !== void 0 ? opts : { dateStyle: 'medium' }).format(new Date(d));
275
+ }
276
+ catch (_a) {
277
+ return String(d);
278
+ }
279
+ },
280
+ dateTime: (d, opts) => {
281
+ try {
282
+ return new Intl.DateTimeFormat(current, opts !== null && opts !== void 0 ? opts : { dateStyle: 'medium', timeStyle: 'short' }).format(new Date(d));
283
+ }
284
+ catch (_a) {
285
+ return String(d);
286
+ }
287
+ },
288
+ };
289
+ /** Forget loaded catalogs and listeners (tests). */
290
+ export function _reset() {
291
+ source = 'en';
292
+ current = 'en';
293
+ base = null;
294
+ loaded.clear();
295
+ supplied.clear();
296
+ listeners.clear();
297
+ version = 0;
298
+ }
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export * from "./api/index.js";
3
3
  export * from "./types/index.js";
4
4
  export { iframe } from "./iframe.js";
5
5
  export { readContext } from "./context.js";
6
+ export * as i18n from "./i18n.js";
6
7
  export * as adminViews from "./adminViews.js";
7
8
  export type { NavigateRequest, NavigateTarget, OpenAppRequest } from "./adminViews.js";
8
9
  export { widgetStyleVars, widgetStyleControls, readableOn, WIDGET_STYLE_VARS } from "./widgetStyle.js";
package/dist/index.js CHANGED
@@ -7,6 +7,8 @@ export * from "./types/index.js";
7
7
  export { iframe } from "./iframe.js";
8
8
  // App context reader (props → hash → search), for pages and containers alike
9
9
  export { readContext } from "./context.js";
10
+ import * as i18n_1 from "./i18n.js";
11
+ export { i18n_1 as i18n };
10
12
  import * as adminViews_1 from "./adminViews.js";
11
13
  export { adminViews_1 as adminViews };
12
14
  export { widgetStyleVars, widgetStyleControls, readableOn, WIDGET_STYLE_VARS } from "./widgetStyle.js";
package/dist/openapi.yaml CHANGED
@@ -106,6 +106,8 @@ tags:
106
106
  description: Order records and line items.
107
107
  - name: partner
108
108
  description: partner API
109
+ - name: places
110
+ description: places API
109
111
  - name: product
110
112
  description: Single product operations.
111
113
  - name: products
@@ -7262,6 +7264,40 @@ paths:
7262
7264
  description: Unauthorized
7263
7265
  404:
7264
7266
  description: Not found
7267
+ /admin/collection/{collectionId}/places/move:
7268
+ post:
7269
+ tags:
7270
+ - places
7271
+ summary: "Move items (by membership), chips without an item (by membership) or containers (re-parented) into `to`, or out of every place with `to: null`."
7272
+ operationId: places_move
7273
+ security:
7274
+ - bearerAuth: []
7275
+ parameters:
7276
+ - name: collectionId
7277
+ in: path
7278
+ required: true
7279
+ schema:
7280
+ type: string
7281
+ responses:
7282
+ 200:
7283
+ description: Success
7284
+ content:
7285
+ application/json:
7286
+ schema:
7287
+ $ref: "#/components/schemas/PlaceMoveResult"
7288
+ 400:
7289
+ description: Bad request
7290
+ 401:
7291
+ description: Unauthorized
7292
+ 404:
7293
+ description: Not found
7294
+ requestBody:
7295
+ required: true
7296
+ content:
7297
+ application/json:
7298
+ schema:
7299
+ type: object
7300
+ additionalProperties: true
7265
7301
  /admin/collection/{collectionId}/product:
7266
7302
  post:
7267
7303
  tags:
@@ -15670,6 +15706,16 @@ paths:
15670
15706
  required: true
15671
15707
  schema:
15672
15708
  type: string
15709
+ - name: from
15710
+ in: query
15711
+ required: false
15712
+ schema:
15713
+ type: string
15714
+ - name: to
15715
+ in: query
15716
+ required: false
15717
+ schema:
15718
+ type: string
15673
15719
  responses:
15674
15720
  200:
15675
15721
  description: Success
@@ -27634,6 +27680,8 @@ components:
27634
27680
  properties:
27635
27681
  changed:
27636
27682
  type: number
27683
+ wholeRange:
27684
+ type: boolean
27637
27685
  skipped:
27638
27686
  type: array
27639
27687
  items:
@@ -27722,6 +27770,17 @@ components:
27722
27770
  additionalProperties: true
27723
27771
  codes:
27724
27772
  type: number
27773
+ codeSource:
27774
+ type: string
27775
+ enum:
27776
+ - stored
27777
+ - computed
27778
+ sigBits:
27779
+ type: number
27780
+ bareCodes:
27781
+ type: boolean
27782
+ unassignedUrl:
27783
+ type: string
27725
27784
  deleted:
27726
27785
  type: boolean
27727
27786
  createdAt:
@@ -27767,9 +27826,104 @@ components:
27767
27826
  $ref: "#/components/schemas/ClaimSetTagType"
27768
27827
  tapDomain:
27769
27828
  type: string
27829
+ codeSource:
27830
+ type: string
27831
+ enum:
27832
+ - stored
27833
+ - computed
27834
+ sigBits:
27835
+ type: number
27836
+ bareCodes:
27837
+ type: boolean
27838
+ unassignedUrl:
27839
+ type: string
27770
27840
  required:
27771
27841
  - name
27772
27842
  - tagType
27843
+ TagCodeRef:
27844
+ type: object
27845
+ properties:
27846
+ scan:
27847
+ type: string
27848
+ url:
27849
+ type: string
27850
+ claimSetId:
27851
+ type: string
27852
+ code:
27853
+ type: string
27854
+ tagId:
27855
+ type: string
27856
+ TagCodeAttachRequest:
27857
+ type: object
27858
+ properties:
27859
+ productId:
27860
+ type: string
27861
+ proofId:
27862
+ type: string
27863
+ containerId:
27864
+ type: string
27865
+ container:
27866
+ type: object
27867
+ additionalProperties: true
27868
+ TagCodeState:
27869
+ type: object
27870
+ properties:
27871
+ kind:
27872
+ type: string
27873
+ enum:
27874
+ - claim
27875
+ - chip
27876
+ claimSetId:
27877
+ type: string
27878
+ code:
27879
+ type: string
27880
+ url:
27881
+ type: string
27882
+ computed:
27883
+ type: boolean
27884
+ tagId:
27885
+ type: string
27886
+ tagType:
27887
+ type: string
27888
+ enum:
27889
+ - chip
27890
+ status:
27891
+ type: string
27892
+ enum:
27893
+ - free
27894
+ - attached
27895
+ - elsewhere
27896
+ on:
27897
+ $ref: "#/components/schemas/TagCodeOn"
27898
+ productId:
27899
+ type: string
27900
+ proofId:
27901
+ type: string
27902
+ required:
27903
+ - kind
27904
+ - tagType
27905
+ - status
27906
+ PlaceMoveResult:
27907
+ type: object
27908
+ properties:
27909
+ moved:
27910
+ type: array
27911
+ items:
27912
+ type: object
27913
+ additionalProperties: true
27914
+ unchanged:
27915
+ type: array
27916
+ items:
27917
+ $ref: "#/components/schemas/PlaceMoveItem"
27918
+ refused:
27919
+ type: array
27920
+ items:
27921
+ type: object
27922
+ additionalProperties: true
27923
+ required:
27924
+ - moved
27925
+ - unchanged
27926
+ - refused
27773
27927
  ClaimSetScope:
27774
27928
  type: object
27775
27929
  properties:
@@ -27777,6 +27931,14 @@ components:
27777
27931
  type: string
27778
27932
  required:
27779
27933
  - collectionId
27934
+ PlaceMoveItem:
27935
+ type: object
27936
+ properties:
27937
+ productId:
27938
+ type: object
27939
+ additionalProperties: true
27940
+ required:
27941
+ - productId
27780
27942
  ClaimSetTagType:
27781
27943
  type: string
27782
27944
  enum:
@@ -27815,6 +27977,9 @@ components:
27815
27977
  - duplicate_uid
27816
27978
  - uid_in_use
27817
27979
  - uid_conflict
27980
+ TagCodeOn:
27981
+ type: object
27982
+ additionalProperties: true
27818
27983
  ClientErrorReport:
27819
27984
  type: object
27820
27985
  properties:
@@ -29671,11 +29836,16 @@ components:
29671
29836
  FindContainersForItemResponse:
29672
29837
  type: object
29673
29838
  properties:
29839
+ items:
29840
+ type: array
29841
+ items:
29842
+ $ref: "#/components/schemas/ContainerItem"
29674
29843
  containers:
29675
29844
  type: array
29676
29845
  items:
29677
29846
  $ref: "#/components/schemas/Container"
29678
29847
  required:
29848
+ - items
29679
29849
  - containers
29680
29850
  ContainerItemsResponse:
29681
29851
  type: object
@@ -176,7 +176,7 @@ export interface CreateClaimSetRangeRequest {
176
176
  /** Default 'range'. Owners and admins make ranges and open ranges; assigners may make groups too. */
177
177
  kind?: ClaimSetRangeKind;
178
178
  name: string;
179
- /** 1 to 10,000 (a range); ignored for open ranges and groups */
179
+ /** 1 to 10,000 (a range), or up to 1,000,000 in a computed set; ignored for open ranges and groups */
180
180
  quantity?: number;
181
181
  /** Pre-assign every tag at mint time (you must administer the collection) */
182
182
  intendedCollectionId?: string;
@@ -302,6 +302,8 @@ export interface AssignClaimSetRangeRequest {
302
302
  }
303
303
  export interface AssignClaimSetRangeResponse {
304
304
  changed: number;
305
+ /** A whole computed run, assigned on the range itself (one write, however many tags) */
306
+ wholeRange?: boolean;
305
307
  skipped: Array<{
306
308
  code: string;
307
309
  index: number;
@@ -349,6 +351,14 @@ export interface PartnerClaimSet {
349
351
  id: string | null;
350
352
  };
351
353
  codes: number;
354
+ /** 'computed': codes are worked out from their index, nothing stored until one is claimed (QR only) */
355
+ codeSource?: 'stored' | 'computed';
356
+ /** computed sets: the signature size, 16 to 32 bits (default 24) */
357
+ sigBits?: number;
358
+ /** computed sets: this set answers bare codes on its domain, https://{tapDomain}/{code} */
359
+ bareCodes?: boolean;
360
+ /** computed sets: where an unused code's scan goes; {set} and {code} are filled in */
361
+ unassignedUrl?: string | null;
352
362
  deleted: boolean;
353
363
  createdAt: string | null;
354
364
  }
@@ -369,4 +379,99 @@ export interface CreatePartnerClaimSetRequest {
369
379
  tagType: ClaimSetTagType;
370
380
  /** One of the partner's tap domains; default smartlinks.app */
371
381
  tapDomain?: string;
382
+ /**
383
+ * 'computed' (QR only): codes are worked out from their index and nothing is stored per code until one is
384
+ * claimed, so a run can hold up to 1,000,000 tags. Default 'stored'.
385
+ */
386
+ codeSource?: 'stored' | 'computed';
387
+ /** computed sets: signature size, 16 to 32 bits; default 24 (about 1 in 16.7 million guesses passes) */
388
+ sigBits?: number;
389
+ /** computed sets: answer bare codes on the tap domain (https://{domain}/{code}); one set per domain */
390
+ bareCodes?: boolean;
391
+ /** computed sets: a full https:// address for an unused code's scan, with {set} and {code} placeholders */
392
+ unassignedUrl?: string;
393
+ }
394
+ /**
395
+ * A scanned tag. Any one of: what a scanner read (`scan`: an address is a claim code, anything else a chip id), the
396
+ * address (`url`), a claim set and code, or a chip's id in the tags table (`tagId`: an RFID EPC or NFC UID).
397
+ */
398
+ export interface TagCodeRef {
399
+ scan?: string;
400
+ /** https://{domain}/{code} or https://{domain}/t/{set}/{code} */
401
+ url?: string;
402
+ claimSetId?: string;
403
+ code?: string;
404
+ /** An RFID EPC or NFC UID */
405
+ tagId?: string;
406
+ }
407
+ /** Attach a tag to an item (productId + proofId), an existing container (containerId), or a new box (container). */
408
+ export interface TagCodeAttachRequest extends TagCodeRef {
409
+ /** The item's type (a product) */
410
+ productId?: string;
411
+ /** The item (a proof) */
412
+ proofId?: string;
413
+ /** An existing container this tag is the label on */
414
+ containerId?: string;
415
+ /** A new box (or bag, shelf…) labelled by this tag */
416
+ container?: {
417
+ name: string;
418
+ containerType?: string;
419
+ parentContainerId?: string;
420
+ };
421
+ }
422
+ /** What a tag is on: an item, a container it labels, or (older RFID) just a product. */
423
+ export type TagCodeOn = {
424
+ type: 'item';
425
+ productId: string | null;
426
+ proofId: string;
427
+ } | {
428
+ type: 'container';
429
+ containerId: string;
430
+ name?: string | null;
431
+ containerType?: string;
432
+ } | {
433
+ type: 'product';
434
+ productId: string;
435
+ };
436
+ export interface TagCodeState {
437
+ /** claim: a claim-set code (QR, or an NFC claim code); chip: a tags-table chip (RFID EPC, NFC UID) */
438
+ kind: 'claim' | 'chip';
439
+ /** claim codes */
440
+ claimSetId?: string;
441
+ code?: string;
442
+ /** The address a claim code carries */
443
+ url?: string;
444
+ /** A computed set's code (printed QR, nothing stored until attached) */
445
+ computed?: boolean;
446
+ /** chips */
447
+ tagId?: string;
448
+ tagType: ClaimSetTagType | 'chip';
449
+ /** free: may be attached here; attached: on one of this collection's things; elsewhere: another organisation's */
450
+ status: 'free' | 'attached' | 'elsewhere';
451
+ /** Only for this collection's own tags */
452
+ on?: TagCodeOn | null;
453
+ productId?: string | null;
454
+ proofId?: string | null;
455
+ }
456
+ /** places.move: one thing to move. */
457
+ export type PlaceMoveItem = {
458
+ productId: string;
459
+ proofId: string;
460
+ } | {
461
+ tagId: string;
462
+ } | {
463
+ containerId: string;
464
+ };
465
+ export interface PlaceMoveResult {
466
+ moved: Array<{
467
+ item: PlaceMoveItem;
468
+ from: string | null;
469
+ to: string | null;
470
+ }>;
471
+ unchanged: PlaceMoveItem[];
472
+ refused: Array<{
473
+ item: PlaceMoveItem;
474
+ errorCode: string;
475
+ errorText: string;
476
+ }>;
372
477
  }
@@ -139,7 +139,9 @@ export interface ListContainersResponse {
139
139
  export interface PublicListContainersResponse {
140
140
  containers: Container[];
141
141
  }
142
+ /** What findForItem answers: the item's current membership rows (each has `containerId`) and those containers. */
142
143
  export interface FindContainersForItemResponse {
144
+ items: ContainerItem[];
143
145
  containers: Container[];
144
146
  }
145
147
  export interface ContainerItemsResponse {