@wix/himalaya-cli 0.1592.0 → 0.1594.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.
Files changed (38) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/contacts/src/index.d.ts +52 -0
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/sdk-types/src/capabilities.generated.d.ts +1 -1
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/audio-record.mjs +1 -1
  4. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/calendar.mjs +1 -1
  5. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/calls.mjs +1 -1
  6. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/contacts.mjs +90 -1
  7. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/location.mjs +1 -1
  8. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/motion.mjs +1 -1
  9. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/photos.mjs +1 -1
  10. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdk-types.mjs +1 -1
  11. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/tasks.mjs +1 -1
  12. package/dist/cli.mjs +47 -41
  13. package/dist/preview-assets.generated.bin +0 -0
  14. package/guides/one-app-to-himi-app.md +12 -0
  15. package/guides/sdk-reference.json +60 -0
  16. package/guides/web-page-sdk-reference.md +1 -1
  17. package/package.json +2 -2
  18. package/templates/beauty-salon/dev/index.ts +216 -8
  19. package/templates/beauty-salon/tier5-src/_shared/himi-store-facets.ts +26 -2
  20. package/templates/beauty-salon/tier5-src/himi-branded-lite-category/index.ts +3 -3
  21. package/templates/beauty-salon/tier5-src/himi-branded-lite-shop/index.ts +4 -4
  22. package/templates/branded-lite/dev/index.ts +216 -8
  23. package/templates/branded-lite/tier5-src/_shared/business-chat-transport.ts +9 -0
  24. package/templates/branded-lite/tier5-src/_shared/himi-store-facets.ts +26 -2
  25. package/templates/branded-lite/tier5-src/himi-branded-lite-category/index.ts +3 -3
  26. package/templates/branded-lite/tier5-src/himi-branded-lite-shop/index.ts +3 -3
  27. package/templates/gym-fitness/dev/index.ts +216 -8
  28. package/templates/gym-fitness/tier5-src/_shared/himi-store-facets.ts +26 -2
  29. package/templates/gym-fitness/tier5-src/himi-branded-lite-category/index.ts +3 -3
  30. package/templates/gym-fitness/tier5-src/himi-branded-lite-shop/index.ts +4 -4
  31. package/templates/portfolio-creative/dev/index.ts +216 -8
  32. package/templates/portfolio-creative/tier5-src/_shared/himi-store-facets.ts +26 -2
  33. package/templates/portfolio-creative/tier5-src/himi-branded-lite-category/index.ts +3 -3
  34. package/templates/portfolio-creative/tier5-src/himi-branded-lite-shop/index.ts +4 -4
  35. package/templates/retail-store/dev/index.ts +216 -8
  36. package/templates/retail-store/tier5-src/_shared/himi-store-facets.ts +26 -2
  37. package/templates/retail-store/tier5-src/himi-branded-lite-category/index.ts +3 -3
  38. package/templates/retail-store/tier5-src/himi-branded-lite-shop/index.ts +3 -3
@@ -13,4 +13,56 @@ export declare function getPermissionStatus(): Promise<PermissionStatus>;
13
13
  export declare function requestPermission(): Promise<PermissionStatus>;
14
14
  /** Search contacts by name (requires read permission). [] when denied/no match. */
15
15
  export declare function search(query: string, limit?: number): Promise<Contact[]>;
16
+ /** One labelled phone number or email address. `label` is free text ("work", "mobile"…);
17
+ * each host maps the common ones to its native label and keeps the rest as a custom label. */
18
+ export interface ContactField {
19
+ label?: string;
20
+ value: string;
21
+ }
22
+ /** A contact to create. At least one of `givenName`, `familyName` or `organization` must be
23
+ * non-blank; every list holds at most {@link MAX_CONTACT_ENTRIES} entries. */
24
+ export interface NewContact {
25
+ givenName?: string;
26
+ familyName?: string;
27
+ organization?: string;
28
+ phones?: ContactField[];
29
+ emails?: ContactField[];
30
+ urls?: string[];
31
+ note?: string;
32
+ }
33
+ /** The most entries `phones`, `emails` or `urls` may carry. */
34
+ export declare const MAX_CONTACT_ENTRIES = 20;
35
+ /** Why a create verb rejected. */
36
+ export type ContactsErrorCode = "invalid_contact" | "permission_denied" | "unavailable";
37
+ /** A create-verb rejection: an `Error` named "ContactsError" carrying a stable `code`. (A plain
38
+ * Error, not a subclass — Tier-5 bundles target an engine without class syntax.) Branch on
39
+ * `isContactsError(e) && e.code === "permission_denied"`. */
40
+ export interface ContactsError extends Error {
41
+ name: "ContactsError";
42
+ code: ContactsErrorCode;
43
+ }
44
+ /** Build a coded contacts rejection. */
45
+ export declare function contactsError(code: ContactsErrorCode, message?: string): ContactsError;
46
+ /** Whether `e` is a coded contacts rejection. */
47
+ export declare function isContactsError(e: unknown): e is ContactsError;
48
+ /** Validate and normalize a {@link NewContact}: strings trimmed, blank entries dropped, blank
49
+ * fields omitted. Throws `invalid_contact` when there is no name or organization, or a list
50
+ * holds more than {@link MAX_CONTACT_ENTRIES} entries. Every host re-checks the same rules. */
51
+ export declare function normalizeNewContact(contact: NewContact): NewContact;
52
+ /** Open the OS new-contact sheet prefilled with `contact` — the recommended way to save a
53
+ * contact: it needs NO contacts permission, because the user reviews and confirms the save.
54
+ * Resolves `{ saved: true }` when the user saved it, `{ saved: false }` on cancel. Web
55
+ * downloads a `.vcf` instead (and resolves `saved: true` once the download is handed off).
56
+ * Rejects `invalid_contact` (see {@link normalizeNewContact}) or `unavailable`. */
57
+ export declare function presentNewContact(contact: NewContact): Promise<{
58
+ saved: boolean;
59
+ }>;
60
+ /** Write `contact` straight into the address book and resolve its new `id`. Needs contacts
61
+ * WRITE permission — ask with {@link requestPermission} first; without it this rejects
62
+ * `permission_denied` (it never prompts). Rejects `invalid_contact`, or `unavailable` where
63
+ * the host has no address book (web). Prefer {@link presentNewContact} unless the app already
64
+ * holds the permission. */
65
+ export declare function add(contact: NewContact): Promise<{
66
+ id: string;
67
+ }>;
16
68
  export declare const version = 1;
@@ -9,7 +9,7 @@ export declare const CAPABILITY_REGISTRY: {
9
9
  readonly calls: readonly ["answer", "availability", "getPermissionStatus", "getState", "hangup", "listCalls", "offer", "receiveSignal", "reject", "requestPermission", "setMuted", "setRingback", "setSpeaker", "signalNext", "signalStart", "signalStop", "start", "subscribeEvents"];
10
10
  readonly camera: readonly ["capture", "pickDocument", "prepareImage", "scanQR"];
11
11
  readonly clipboard: readonly ["hasImage", "hasText", "readText", "writeImage", "writeText"];
12
- readonly contacts: readonly ["getPermissionStatus", "pick", "requestPermission", "search"];
12
+ readonly contacts: readonly ["add", "getPermissionStatus", "pick", "presentNewContact", "requestPermission", "search"];
13
13
  readonly file_picker: readonly ["pick", "pickDirectoryForExport"];
14
14
  readonly files: readonly ["download", "export", "list", "readText", "remove", "stat", "storageInfo", "write"];
15
15
  readonly godot: readonly ["loadPack", "release", "send"];
@@ -24,7 +24,7 @@ var CAPABILITY_REGISTRY = {
24
24
  "calls": ["answer", "availability", "getPermissionStatus", "getState", "hangup", "listCalls", "offer", "receiveSignal", "reject", "requestPermission", "setMuted", "setRingback", "setSpeaker", "signalNext", "signalStart", "signalStop", "start", "subscribeEvents"],
25
25
  "camera": ["capture", "pickDocument", "prepareImage", "scanQR"],
26
26
  "clipboard": ["hasImage", "hasText", "readText", "writeImage", "writeText"],
27
- "contacts": ["getPermissionStatus", "pick", "requestPermission", "search"],
27
+ "contacts": ["add", "getPermissionStatus", "pick", "presentNewContact", "requestPermission", "search"],
28
28
  "file_picker": ["pick", "pickDirectoryForExport"],
29
29
  "files": ["download", "export", "list", "readText", "remove", "stat", "storageInfo", "write"],
30
30
  "godot": ["loadPack", "release", "send"],
@@ -24,7 +24,7 @@ var CAPABILITY_REGISTRY = {
24
24
  "calls": ["answer", "availability", "getPermissionStatus", "getState", "hangup", "listCalls", "offer", "receiveSignal", "reject", "requestPermission", "setMuted", "setRingback", "setSpeaker", "signalNext", "signalStart", "signalStop", "start", "subscribeEvents"],
25
25
  "camera": ["capture", "pickDocument", "prepareImage", "scanQR"],
26
26
  "clipboard": ["hasImage", "hasText", "readText", "writeImage", "writeText"],
27
- "contacts": ["getPermissionStatus", "pick", "requestPermission", "search"],
27
+ "contacts": ["add", "getPermissionStatus", "pick", "presentNewContact", "requestPermission", "search"],
28
28
  "file_picker": ["pick", "pickDirectoryForExport"],
29
29
  "files": ["download", "export", "list", "readText", "remove", "stat", "storageInfo", "write"],
30
30
  "godot": ["loadPack", "release", "send"],
@@ -24,7 +24,7 @@ var CAPABILITY_REGISTRY = {
24
24
  "calls": ["answer", "availability", "getPermissionStatus", "getState", "hangup", "listCalls", "offer", "receiveSignal", "reject", "requestPermission", "setMuted", "setRingback", "setSpeaker", "signalNext", "signalStart", "signalStop", "start", "subscribeEvents"],
25
25
  "camera": ["capture", "pickDocument", "prepareImage", "scanQR"],
26
26
  "clipboard": ["hasImage", "hasText", "readText", "writeImage", "writeText"],
27
- "contacts": ["getPermissionStatus", "pick", "requestPermission", "search"],
27
+ "contacts": ["add", "getPermissionStatus", "pick", "presentNewContact", "requestPermission", "search"],
28
28
  "file_picker": ["pick", "pickDirectoryForExport"],
29
29
  "files": ["download", "export", "list", "readText", "remove", "stat", "storageInfo", "write"],
30
30
  "godot": ["loadPack", "release", "send"],
@@ -24,7 +24,7 @@ var CAPABILITY_REGISTRY = {
24
24
  "calls": ["answer", "availability", "getPermissionStatus", "getState", "hangup", "listCalls", "offer", "receiveSignal", "reject", "requestPermission", "setMuted", "setRingback", "setSpeaker", "signalNext", "signalStart", "signalStop", "start", "subscribeEvents"],
25
25
  "camera": ["capture", "pickDocument", "prepareImage", "scanQR"],
26
26
  "clipboard": ["hasImage", "hasText", "readText", "writeImage", "writeText"],
27
- "contacts": ["getPermissionStatus", "pick", "requestPermission", "search"],
27
+ "contacts": ["add", "getPermissionStatus", "pick", "presentNewContact", "requestPermission", "search"],
28
28
  "file_picker": ["pick", "pickDirectoryForExport"],
29
29
  "files": ["download", "export", "list", "readText", "remove", "stat", "storageInfo", "write"],
30
30
  "godot": ["loadPack", "release", "send"],
@@ -86,10 +86,99 @@ async function search(query, limit) {
86
86
  const r = await dispatch("capability.contacts.search", params);
87
87
  return Array.isArray(r?.items) ? r.items : [];
88
88
  }
89
+ var MAX_CONTACT_ENTRIES = 20;
90
+ var CODES = ["invalid_contact", "permission_denied", "unavailable"];
91
+ function contactsError(code, message) {
92
+ const text = !message ? code : message.startsWith(code) ? message : `${code}: ${message}`;
93
+ const err = new Error(text);
94
+ err.name = "ContactsError";
95
+ err.code = code;
96
+ return err;
97
+ }
98
+ function isContactsError(e) {
99
+ return e instanceof Error && e.name === "ContactsError" && CODES.includes(e.code);
100
+ }
101
+ function codeOf(err) {
102
+ const msg = err instanceof Error ? err.message : String(err ?? "");
103
+ let best = null;
104
+ for (const c of CODES) {
105
+ const m = new RegExp(`(^|[^a-z_])${c}([^a-z_]|$)`).exec(msg);
106
+ if (!m) continue;
107
+ const at = m.index + m[1].length;
108
+ if (!best || at < best.at) best = { code: c, at };
109
+ }
110
+ return best?.code ?? null;
111
+ }
112
+ var trimmed = (v) => typeof v === "string" ? v.trim() : "";
113
+ function fields(list, name) {
114
+ if (list == null) return [];
115
+ if (!Array.isArray(list)) throw contactsError("invalid_contact", `${name} must be an array`);
116
+ if (list.length > MAX_CONTACT_ENTRIES) throw contactsError("invalid_contact", `${name} holds more than ${MAX_CONTACT_ENTRIES} entries`);
117
+ const out = [];
118
+ for (const entry of list) {
119
+ const value = trimmed(entry?.value);
120
+ if (!value) continue;
121
+ const label = trimmed(entry.label);
122
+ out.push(label ? { label, value } : { value });
123
+ }
124
+ return out;
125
+ }
126
+ function normalizeNewContact(contact) {
127
+ if (contact == null || typeof contact !== "object") throw contactsError("invalid_contact", "contact must be an object");
128
+ const out = {};
129
+ const givenName = trimmed(contact.givenName);
130
+ const familyName = trimmed(contact.familyName);
131
+ const organization = trimmed(contact.organization);
132
+ if (!givenName && !familyName && !organization) {
133
+ throw contactsError("invalid_contact", "a contact needs a givenName, familyName or organization");
134
+ }
135
+ if (givenName) out.givenName = givenName;
136
+ if (familyName) out.familyName = familyName;
137
+ if (organization) out.organization = organization;
138
+ const phones = fields(contact.phones, "phones");
139
+ if (phones.length) out.phones = phones;
140
+ const emails = fields(contact.emails, "emails");
141
+ if (emails.length) out.emails = emails;
142
+ if (contact.urls != null) {
143
+ if (!Array.isArray(contact.urls)) throw contactsError("invalid_contact", "urls must be an array");
144
+ if (contact.urls.length > MAX_CONTACT_ENTRIES) throw contactsError("invalid_contact", `urls holds more than ${MAX_CONTACT_ENTRIES} entries`);
145
+ const urls = contact.urls.map(trimmed).filter((u) => u.length > 0);
146
+ if (urls.length) out.urls = urls;
147
+ }
148
+ const note = trimmed(contact.note);
149
+ if (note) out.note = note;
150
+ return out;
151
+ }
152
+ async function coded(call) {
153
+ try {
154
+ return await call();
155
+ } catch (err) {
156
+ const code = codeOf(err);
157
+ if (code) throw contactsError(code, err instanceof Error ? err.message : String(err));
158
+ throw err;
159
+ }
160
+ }
161
+ async function presentNewContact(contact) {
162
+ const wire = { contact: JSON.stringify(normalizeNewContact(contact)) };
163
+ const r = await coded(() => dispatch("capability.contacts.presentNewContact", wire));
164
+ return { saved: r?.saved === true };
165
+ }
166
+ async function add(contact) {
167
+ const wire = { contact: JSON.stringify(normalizeNewContact(contact)) };
168
+ const r = await coded(() => dispatch("capability.contacts.add", wire));
169
+ if (typeof r?.id !== "string" || r.id.length === 0) throw contactsError("unavailable", "the host returned no contact id");
170
+ return { id: r.id };
171
+ }
89
172
  var version = 1;
90
173
  export {
174
+ MAX_CONTACT_ENTRIES,
175
+ add,
176
+ contactsError,
91
177
  getPermissionStatus,
178
+ isContactsError,
179
+ normalizeNewContact,
92
180
  pick,
181
+ presentNewContact,
93
182
  requestPermission,
94
183
  search,
95
184
  version
@@ -24,7 +24,7 @@ var CAPABILITY_REGISTRY = {
24
24
  "calls": ["answer", "availability", "getPermissionStatus", "getState", "hangup", "listCalls", "offer", "receiveSignal", "reject", "requestPermission", "setMuted", "setRingback", "setSpeaker", "signalNext", "signalStart", "signalStop", "start", "subscribeEvents"],
25
25
  "camera": ["capture", "pickDocument", "prepareImage", "scanQR"],
26
26
  "clipboard": ["hasImage", "hasText", "readText", "writeImage", "writeText"],
27
- "contacts": ["getPermissionStatus", "pick", "requestPermission", "search"],
27
+ "contacts": ["add", "getPermissionStatus", "pick", "presentNewContact", "requestPermission", "search"],
28
28
  "file_picker": ["pick", "pickDirectoryForExport"],
29
29
  "files": ["download", "export", "list", "readText", "remove", "stat", "storageInfo", "write"],
30
30
  "godot": ["loadPack", "release", "send"],
@@ -24,7 +24,7 @@ var CAPABILITY_REGISTRY = {
24
24
  "calls": ["answer", "availability", "getPermissionStatus", "getState", "hangup", "listCalls", "offer", "receiveSignal", "reject", "requestPermission", "setMuted", "setRingback", "setSpeaker", "signalNext", "signalStart", "signalStop", "start", "subscribeEvents"],
25
25
  "camera": ["capture", "pickDocument", "prepareImage", "scanQR"],
26
26
  "clipboard": ["hasImage", "hasText", "readText", "writeImage", "writeText"],
27
- "contacts": ["getPermissionStatus", "pick", "requestPermission", "search"],
27
+ "contacts": ["add", "getPermissionStatus", "pick", "presentNewContact", "requestPermission", "search"],
28
28
  "file_picker": ["pick", "pickDirectoryForExport"],
29
29
  "files": ["download", "export", "list", "readText", "remove", "stat", "storageInfo", "write"],
30
30
  "godot": ["loadPack", "release", "send"],
@@ -24,7 +24,7 @@ var CAPABILITY_REGISTRY = {
24
24
  "calls": ["answer", "availability", "getPermissionStatus", "getState", "hangup", "listCalls", "offer", "receiveSignal", "reject", "requestPermission", "setMuted", "setRingback", "setSpeaker", "signalNext", "signalStart", "signalStop", "start", "subscribeEvents"],
25
25
  "camera": ["capture", "pickDocument", "prepareImage", "scanQR"],
26
26
  "clipboard": ["hasImage", "hasText", "readText", "writeImage", "writeText"],
27
- "contacts": ["getPermissionStatus", "pick", "requestPermission", "search"],
27
+ "contacts": ["add", "getPermissionStatus", "pick", "presentNewContact", "requestPermission", "search"],
28
28
  "file_picker": ["pick", "pickDirectoryForExport"],
29
29
  "files": ["download", "export", "list", "readText", "remove", "stat", "storageInfo", "write"],
30
30
  "godot": ["loadPack", "release", "send"],
@@ -9,7 +9,7 @@ var CAPABILITY_REGISTRY = {
9
9
  "calls": ["answer", "availability", "getPermissionStatus", "getState", "hangup", "listCalls", "offer", "receiveSignal", "reject", "requestPermission", "setMuted", "setRingback", "setSpeaker", "signalNext", "signalStart", "signalStop", "start", "subscribeEvents"],
10
10
  "camera": ["capture", "pickDocument", "prepareImage", "scanQR"],
11
11
  "clipboard": ["hasImage", "hasText", "readText", "writeImage", "writeText"],
12
- "contacts": ["getPermissionStatus", "pick", "requestPermission", "search"],
12
+ "contacts": ["add", "getPermissionStatus", "pick", "presentNewContact", "requestPermission", "search"],
13
13
  "file_picker": ["pick", "pickDirectoryForExport"],
14
14
  "files": ["download", "export", "list", "readText", "remove", "stat", "storageInfo", "write"],
15
15
  "godot": ["loadPack", "release", "send"],
@@ -24,7 +24,7 @@ var CAPABILITY_REGISTRY = {
24
24
  "calls": ["answer", "availability", "getPermissionStatus", "getState", "hangup", "listCalls", "offer", "receiveSignal", "reject", "requestPermission", "setMuted", "setRingback", "setSpeaker", "signalNext", "signalStart", "signalStop", "start", "subscribeEvents"],
25
25
  "camera": ["capture", "pickDocument", "prepareImage", "scanQR"],
26
26
  "clipboard": ["hasImage", "hasText", "readText", "writeImage", "writeText"],
27
- "contacts": ["getPermissionStatus", "pick", "requestPermission", "search"],
27
+ "contacts": ["add", "getPermissionStatus", "pick", "presentNewContact", "requestPermission", "search"],
28
28
  "file_picker": ["pick", "pickDirectoryForExport"],
29
29
  "files": ["download", "export", "list", "readText", "remove", "stat", "storageInfo", "write"],
30
30
  "godot": ["loadPack", "release", "send"],