@businessdash/sdk 0.9.60 → 0.9.80

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 (239) hide show
  1. package/README.md +991 -295
  2. package/assets/biab-sw.js +92 -0
  3. package/dist/account-core/index.d.ts +126 -0
  4. package/dist/account-core/index.d.ts.map +1 -0
  5. package/dist/account-core/index.js +191 -0
  6. package/dist/account-core/index.js.map +1 -0
  7. package/dist/account.d.ts +11 -0
  8. package/dist/account.d.ts.map +1 -0
  9. package/dist/account.js +11 -0
  10. package/dist/account.js.map +1 -0
  11. package/dist/auth-handler.d.ts +1 -1
  12. package/dist/auth-links.d.ts +33 -0
  13. package/dist/auth-links.d.ts.map +1 -0
  14. package/dist/auth-links.js +64 -0
  15. package/dist/auth-links.js.map +1 -0
  16. package/dist/blog-core/index.d.ts +112 -0
  17. package/dist/blog-core/index.d.ts.map +1 -0
  18. package/dist/blog-core/index.js +330 -0
  19. package/dist/blog-core/index.js.map +1 -0
  20. package/dist/blog.d.ts +11 -0
  21. package/dist/blog.d.ts.map +1 -0
  22. package/dist/blog.js +11 -0
  23. package/dist/blog.js.map +1 -0
  24. package/dist/chat-core/index.d.ts +97 -0
  25. package/dist/chat-core/index.d.ts.map +1 -0
  26. package/dist/chat-core/index.js +237 -0
  27. package/dist/chat-core/index.js.map +1 -0
  28. package/dist/chat.d.ts +11 -0
  29. package/dist/chat.d.ts.map +1 -0
  30. package/dist/chat.js +11 -0
  31. package/dist/chat.js.map +1 -0
  32. package/dist/checkout-core/index.d.ts +65 -0
  33. package/dist/checkout-core/index.d.ts.map +1 -0
  34. package/dist/checkout-core/index.js +159 -0
  35. package/dist/checkout-core/index.js.map +1 -0
  36. package/dist/checkout.d.ts +10 -0
  37. package/dist/checkout.d.ts.map +1 -0
  38. package/dist/checkout.js +10 -0
  39. package/dist/checkout.js.map +1 -0
  40. package/dist/cli.js +133 -25
  41. package/dist/cli.js.map +1 -1
  42. package/dist/client.d.ts +622 -1
  43. package/dist/client.d.ts.map +1 -1
  44. package/dist/client.js +888 -1
  45. package/dist/client.js.map +1 -1
  46. package/dist/consent-core/index.cjs +107 -0
  47. package/dist/consent-core/index.d.ts +103 -0
  48. package/dist/consent-core/index.d.ts.map +1 -0
  49. package/dist/consent-core/index.js +157 -0
  50. package/dist/consent-core/index.js.map +1 -0
  51. package/dist/contracts.d.ts +3526 -767
  52. package/dist/contracts.d.ts.map +1 -1
  53. package/dist/contracts.js +571 -4
  54. package/dist/contracts.js.map +1 -1
  55. package/dist/data-model-schema.d.ts +1 -1
  56. package/dist/data-model-schema.d.ts.map +1 -1
  57. package/dist/element.d.ts +30 -0
  58. package/dist/element.d.ts.map +1 -1
  59. package/dist/element.js +56 -0
  60. package/dist/element.js.map +1 -1
  61. package/dist/embed-protocol.d.ts +86 -0
  62. package/dist/embed-protocol.d.ts.map +1 -0
  63. package/dist/embed-protocol.js +60 -0
  64. package/dist/embed-protocol.js.map +1 -0
  65. package/dist/framework-support.d.ts +122 -0
  66. package/dist/framework-support.d.ts.map +1 -0
  67. package/dist/framework-support.js +323 -0
  68. package/dist/framework-support.js.map +1 -0
  69. package/dist/index.cjs +1355 -24
  70. package/dist/legal-core/index.cjs +115 -0
  71. package/dist/legal-core/index.d.ts +160 -0
  72. package/dist/legal-core/index.d.ts.map +1 -0
  73. package/dist/legal-core/index.js +220 -0
  74. package/dist/legal-core/index.js.map +1 -0
  75. package/dist/marketing-core/index.d.ts +66 -0
  76. package/dist/marketing-core/index.d.ts.map +1 -0
  77. package/dist/marketing-core/index.js +154 -0
  78. package/dist/marketing-core/index.js.map +1 -0
  79. package/dist/marketing.d.ts +7 -0
  80. package/dist/marketing.d.ts.map +1 -0
  81. package/dist/marketing.js +7 -0
  82. package/dist/marketing.js.map +1 -0
  83. package/dist/mcp-adapters/index.d.ts +135 -0
  84. package/dist/mcp-adapters/index.d.ts.map +1 -0
  85. package/dist/mcp-adapters/index.js +187 -0
  86. package/dist/mcp-adapters/index.js.map +1 -0
  87. package/dist/mcp-adapters.d.ts +7 -0
  88. package/dist/mcp-adapters.d.ts.map +1 -0
  89. package/dist/mcp-adapters.js +7 -0
  90. package/dist/mcp-adapters.js.map +1 -0
  91. package/dist/model3d-core/index.cjs +95 -0
  92. package/dist/model3d-core/index.d.ts +167 -0
  93. package/dist/model3d-core/index.d.ts.map +1 -0
  94. package/dist/model3d-core/index.js +158 -0
  95. package/dist/model3d-core/index.js.map +1 -0
  96. package/dist/notifications-core/index.cjs +315 -0
  97. package/dist/notifications-core/index.d.ts +229 -0
  98. package/dist/notifications-core/index.d.ts.map +1 -0
  99. package/dist/notifications-core/index.js +445 -0
  100. package/dist/notifications-core/index.js.map +1 -0
  101. package/dist/portal-core/index.d.ts +451 -0
  102. package/dist/portal-core/index.d.ts.map +1 -0
  103. package/dist/portal-core/index.js +819 -0
  104. package/dist/portal-core/index.js.map +1 -0
  105. package/dist/portal.d.ts +7 -0
  106. package/dist/portal.d.ts.map +1 -0
  107. package/dist/portal.js +7 -0
  108. package/dist/portal.js.map +1 -0
  109. package/dist/push-core/index.cjs +171 -0
  110. package/dist/push-core/index.d.ts +149 -0
  111. package/dist/push-core/index.d.ts.map +1 -0
  112. package/dist/push-core/index.js +231 -0
  113. package/dist/push-core/index.js.map +1 -0
  114. package/dist/react-marketing.d.ts +1 -17
  115. package/dist/react-marketing.d.ts.map +1 -1
  116. package/dist/react-marketing.js +4 -0
  117. package/dist/react-marketing.js.map +1 -1
  118. package/dist/react.d.ts +294 -101
  119. package/dist/react.d.ts.map +1 -1
  120. package/dist/react.js +302 -246
  121. package/dist/react.js.map +1 -1
  122. package/dist/seed-core/index.d.ts +354 -0
  123. package/dist/seed-core/index.d.ts.map +1 -0
  124. package/dist/seed-core/index.js +420 -0
  125. package/dist/seed-core/index.js.map +1 -0
  126. package/dist/seed.d.ts +7 -0
  127. package/dist/seed.d.ts.map +1 -0
  128. package/dist/seed.js +7 -0
  129. package/dist/seed.js.map +1 -0
  130. package/dist/seo-core/blog.d.ts +94 -0
  131. package/dist/seo-core/blog.d.ts.map +1 -0
  132. package/dist/seo-core/blog.js +149 -0
  133. package/dist/seo-core/blog.js.map +1 -0
  134. package/dist/seo-core/commerce.d.ts +64 -0
  135. package/dist/seo-core/commerce.d.ts.map +1 -0
  136. package/dist/seo-core/commerce.js +87 -0
  137. package/dist/seo-core/commerce.js.map +1 -0
  138. package/dist/seo-core/index.cjs +751 -0
  139. package/dist/seo-core/index.d.ts +226 -0
  140. package/dist/seo-core/index.d.ts.map +1 -0
  141. package/dist/seo-core/index.js +455 -0
  142. package/dist/seo-core/index.js.map +1 -0
  143. package/dist/seo-core/local.d.ts +181 -0
  144. package/dist/seo-core/local.d.ts.map +1 -0
  145. package/dist/seo-core/local.js +193 -0
  146. package/dist/seo-core/local.js.map +1 -0
  147. package/dist/sitemap-core/index.cjs +167 -0
  148. package/dist/sitemap-core/index.d.ts +155 -0
  149. package/dist/sitemap-core/index.d.ts.map +1 -0
  150. package/dist/sitemap-core/index.js +195 -0
  151. package/dist/sitemap-core/index.js.map +1 -0
  152. package/dist/social-core/index.d.ts +74 -0
  153. package/dist/social-core/index.d.ts.map +1 -0
  154. package/dist/social-core/index.js +72 -0
  155. package/dist/social-core/index.js.map +1 -0
  156. package/dist/social.d.ts +7 -0
  157. package/dist/social.d.ts.map +1 -0
  158. package/dist/social.js +7 -0
  159. package/dist/social.js.map +1 -0
  160. package/dist/solid-compat.d.ts +204 -0
  161. package/dist/solid-compat.d.ts.map +1 -0
  162. package/dist/solid-compat.js +221 -0
  163. package/dist/solid-compat.js.map +1 -0
  164. package/dist/store-core/index.d.ts +141 -0
  165. package/dist/store-core/index.d.ts.map +1 -0
  166. package/dist/store-core/index.js +277 -0
  167. package/dist/store-core/index.js.map +1 -0
  168. package/dist/store.d.ts +12 -0
  169. package/dist/store.d.ts.map +1 -0
  170. package/dist/store.js +12 -0
  171. package/dist/store.js.map +1 -0
  172. package/dist/vanilla.d.ts +111 -0
  173. package/dist/vanilla.d.ts.map +1 -1
  174. package/dist/vanilla.js +206 -0
  175. package/dist/vanilla.js.map +1 -1
  176. package/dist/verify-core/index.d.ts +98 -0
  177. package/dist/verify-core/index.d.ts.map +1 -0
  178. package/dist/verify-core/index.js +186 -0
  179. package/dist/verify-core/index.js.map +1 -0
  180. package/dist/verify.d.ts +8 -0
  181. package/dist/verify.d.ts.map +1 -0
  182. package/dist/verify.js +8 -0
  183. package/dist/verify.js.map +1 -0
  184. package/openapi.json +4516 -1311
  185. package/package.json +128 -11
  186. package/src/account-core/index.ts +309 -0
  187. package/src/account.ts +11 -0
  188. package/src/angular/headless.ts +519 -0
  189. package/src/angular/index.ts +3 -0
  190. package/src/auth-links.ts +76 -0
  191. package/src/blog-core/index.ts +423 -0
  192. package/src/blog.ts +11 -0
  193. package/src/chat-core/index.ts +335 -0
  194. package/src/chat.ts +11 -0
  195. package/src/checkout-core/index.ts +225 -0
  196. package/src/checkout.ts +10 -0
  197. package/src/cli.ts +184 -28
  198. package/src/client.ts +1097 -0
  199. package/src/consent-core/index.ts +213 -0
  200. package/src/contracts.ts +768 -11
  201. package/src/data-model-schema.ts +1 -1
  202. package/src/element.ts +102 -0
  203. package/src/embed-protocol.ts +100 -0
  204. package/src/framework-support.ts +440 -0
  205. package/src/legal-core/index.ts +276 -0
  206. package/src/marketing-core/index.ts +209 -0
  207. package/src/marketing.ts +7 -0
  208. package/src/mcp-adapters/index.ts +264 -0
  209. package/src/mcp-adapters.ts +7 -0
  210. package/src/model3d-core/index.ts +248 -0
  211. package/src/notifications-core/index.ts +650 -0
  212. package/src/portal-core/index.ts +1564 -0
  213. package/src/portal.ts +7 -0
  214. package/src/push-core/index.ts +335 -0
  215. package/src/qwik.tsx +602 -2
  216. package/src/react-marketing.tsx +5 -0
  217. package/src/react.tsx +434 -319
  218. package/src/seed-core/index.ts +735 -0
  219. package/src/seed.ts +7 -0
  220. package/src/seo-core/blog.ts +216 -0
  221. package/src/seo-core/commerce.ts +138 -0
  222. package/src/seo-core/index.ts +605 -0
  223. package/src/seo-core/local.ts +333 -0
  224. package/src/sitemap-core/index.ts +296 -0
  225. package/src/social-core/index.ts +103 -0
  226. package/src/social.ts +7 -0
  227. package/src/solid-compat.tsx +347 -0
  228. package/src/solid-surfaces.tsx +1311 -0
  229. package/src/solid.tsx +82 -60
  230. package/src/store-core/index.ts +426 -0
  231. package/src/store.ts +12 -0
  232. package/src/svelte/SocialLinks.svelte +84 -0
  233. package/src/svelte/headless.ts +435 -0
  234. package/src/svelte/index.ts +9 -0
  235. package/src/vanilla.ts +367 -0
  236. package/src/verify-core/index.ts +288 -0
  237. package/src/verify.ts +8 -0
  238. package/src/vue/headless.ts +527 -0
  239. package/src/vue/index.ts +3 -0
@@ -0,0 +1,354 @@
1
+ /**
2
+ * `@businessdash/sdk/seed` — define a schema, push it, and seed data, from any
3
+ * framework's build step.
4
+ *
5
+ * ## Why this exists alongside the CLI
6
+ *
7
+ * `businessdash sync-data-model` and friends already do this, and they are the
8
+ * right tool at a terminal. They are the wrong tool everywhere else: a Nuxt
9
+ * module, a SvelteKit prerender hook, an Angular builder, a Vite plugin, a
10
+ * Next `instrumentation.ts` or a CI step that already has the credentials
11
+ * loaded cannot shell out to an interactive command and read its output.
12
+ *
13
+ * So the same operations are exposed as plain async functions. Nothing here is
14
+ * framework-specific, because seeding happens at BUILD time — there is no
15
+ * reactivity to bridge, only an integration point per framework, and every
16
+ * framework has one that can call a function.
17
+ *
18
+ * The CLI imports this module rather than the other way round, so there is one
19
+ * implementation of the transport, the auth header and the error handling.
20
+ *
21
+ * ## What can and cannot be seeded
22
+ *
23
+ * The package API decides this, not the SDK:
24
+ *
25
+ * | Target | Seedable | Endpoint |
26
+ * |-----------------------|----------|----------|
27
+ * | Custom-database schema| yes | `data-model/plan` + `draft-schema` |
28
+ * | Custom-database records| yes | `data-model/records` |
29
+ * | Static collections | yes | `collections`, `collections/{slug}/rows` |
30
+ * | Coupons | yes | `coupons` |
31
+ * | Products (+ variants) | yes | `storefront/products` |
32
+ * | Blog posts | yes | `blog/posts` |
33
+ *
34
+ * Products and blog posts were absent from the first version of this module
35
+ * because the package API had no create route for either — the dashboard could
36
+ * do it and the SDK could not. Both routes now exist, so a site can be seeded
37
+ * whole: schema, records, collections, catalogue, content and coupons.
38
+ *
39
+ * ## Pushing a schema does not apply it
40
+ *
41
+ * `pushDataModel` writes the DRAFT slot and returns the plan describing what
42
+ * promoting it would do. Promotion is a separate, deliberate step in the
43
+ * dashboard. That is the platform's design and this module does not route
44
+ * around it: an automated deploy that silently altered a live customer
45
+ * database would be the wrong default.
46
+ *
47
+ * @module
48
+ */
49
+ import type { CollectionDefinition } from "../data-model-schema.js";
50
+ /** Where to seed, and with what credentials. */
51
+ export type SeedTarget = {
52
+ /** Package API key. Needs the data-model and storefront write scopes. */
53
+ apiKey: string;
54
+ /** Site id, from Site Builder → Developer. */
55
+ siteId: string;
56
+ /** Package-API base URL, e.g. `https://businessdash.us/api/package/v1`. */
57
+ baseUrl: string;
58
+ };
59
+ /** A single change promoting a draft schema would make. */
60
+ export type MigrationPlanChange = {
61
+ class: "safe" | "backfill" | "destructive" | "exposure";
62
+ kind: string;
63
+ object: string;
64
+ field?: string;
65
+ option?: string;
66
+ summary: string;
67
+ };
68
+ export type MigrationPlan = {
69
+ changes: MigrationPlanChange[];
70
+ [key: string]: unknown;
71
+ };
72
+ /**
73
+ * One request to the package API, shared by every function here AND by the CLI.
74
+ *
75
+ * Errors carry the server's own message when it sent one. A seeder that failed
76
+ * with `HTTP 403` and nothing else would send someone hunting through their
77
+ * own code for a problem the API already described.
78
+ */
79
+ export declare function callPackageApi(target: SeedTarget, input: {
80
+ path: string;
81
+ method: "GET" | "POST" | "PATCH";
82
+ body?: unknown;
83
+ }): Promise<Record<string, unknown>>;
84
+ /** A schema artifact — the output of `createSchema(...).toJSONSchema()`. */
85
+ export type DataModelArtifact = Record<string, unknown>;
86
+ export type PushDataModelResult = {
87
+ /** What promoting this draft WOULD do. Read it before promoting. */
88
+ plan: MigrationPlan;
89
+ /** Draft version now in the slot, or the existing one when unchanged. */
90
+ version: number | null;
91
+ /** True when the draft already matched — nothing was written. */
92
+ noop: boolean;
93
+ /** True when `dryRun` was set: the plan was computed, nothing uploaded. */
94
+ planOnly: boolean;
95
+ };
96
+ export type PushDataModelOptions = {
97
+ /**
98
+ * Compute the plan and stop. Use this in CI on a pull request: it tells you
99
+ * what a deploy would change without changing anything.
100
+ */
101
+ dryRun?: boolean;
102
+ /** Ask the plan to include dropping objects/fields absent from the schema. */
103
+ prune?: boolean;
104
+ /** Free-text note stored with the draft. */
105
+ note?: string | null;
106
+ /** Optional checksum; the server uses it to detect an unchanged draft. */
107
+ checksum?: string;
108
+ };
109
+ /**
110
+ * Plan, then push a schema into the DRAFT slot.
111
+ *
112
+ * The plan is always computed, even when pushing, because a push whose
113
+ * consequences nobody looked at is how a destructive migration reaches a live
114
+ * database. The returned `plan.changes` carry a `class` — `safe`, `backfill`,
115
+ * `destructive` or `exposure` — which is what a CI gate should branch on.
116
+ */
117
+ export declare function pushDataModel(target: SeedTarget, schema: DataModelArtifact, options?: PushDataModelOptions): Promise<PushDataModelResult>;
118
+ /** Does this plan contain anything that would lose or expose data? */
119
+ export declare function planHasDangerousChanges(plan: MigrationPlan): boolean;
120
+ /** Records keyed by collection name, as the data-model records route expects. */
121
+ export type SeedRecords = Record<string, ReadonlyArray<Record<string, unknown>>>;
122
+ export type SeedRecordsResult = {
123
+ /** How many rows were written per collection, as the server reported. */
124
+ written: Record<string, number>;
125
+ };
126
+ /**
127
+ * Seed rows into the CUSTOM DATABASE (the metadata engine).
128
+ *
129
+ * This is not the same store as `seedCollectionRows` below. The custom database
130
+ * is the schema you defined and promoted; static collections are a simpler
131
+ * key/value-ish store on the site. Mixing them up is easy and the failure is
132
+ * silent — the rows land somewhere real, just not where they were wanted — so
133
+ * the two functions are named for the store rather than for the verb.
134
+ */
135
+ export declare function seedRecords(target: SeedTarget, records: SeedRecords): Promise<SeedRecordsResult>;
136
+ export type StaticCollectionDefinition = {
137
+ name: string;
138
+ slug?: string;
139
+ description?: string;
140
+ fields?: ReadonlyArray<Record<string, unknown>>;
141
+ };
142
+ /** Create a STATIC collection on the site. Idempotent by slug server-side. */
143
+ export declare function seedCollection(target: SeedTarget, definition: StaticCollectionDefinition): Promise<Record<string, unknown>>;
144
+ /**
145
+ * Insert rows into a static collection.
146
+ *
147
+ * Rows go one request each because the route takes one row — batching would
148
+ * mean inventing a bulk endpoint that does not exist. `concurrency` keeps a
149
+ * large seed from opening hundreds of sockets at once.
150
+ */
151
+ export declare function seedCollectionRows(target: SeedTarget, slug: string, rows: ReadonlyArray<{
152
+ rowId?: string;
153
+ data: Record<string, unknown>;
154
+ }>, options?: {
155
+ concurrency?: number;
156
+ }): Promise<{
157
+ written: number;
158
+ }>;
159
+ export type SeedCrossVariantOption = {
160
+ value: string;
161
+ price: number;
162
+ stock?: number | null;
163
+ isLive?: boolean;
164
+ pricingBehavior?: "price" | "note" | null;
165
+ };
166
+ export type SeedCrossVariantTitle = {
167
+ title: string;
168
+ selectionMode?: "single" | "multiple" | null;
169
+ minSelected?: number | null;
170
+ maxSelected?: number | null;
171
+ options?: SeedCrossVariantOption[];
172
+ };
173
+ export type SeedProductVariant = {
174
+ name: string;
175
+ description?: string | null;
176
+ price?: number | null;
177
+ /** Unit COST in integer cents, for margin analytics. */
178
+ costCents?: number | null;
179
+ stock?: number | null;
180
+ isDigital?: boolean;
181
+ isPhysical?: boolean;
182
+ isLive?: boolean;
183
+ attributes?: Record<string, unknown> | null;
184
+ weightInGrams?: number | null;
185
+ requiresShipping?: boolean;
186
+ flatRateShippingCents?: number | null;
187
+ crossVariantTitles?: SeedCrossVariantTitle[];
188
+ };
189
+ export type SeedProduct = {
190
+ name: string;
191
+ description?: string | null;
192
+ categoryId?: string | null;
193
+ storefront?: "web" | "physical" | "all" | null;
194
+ /** Defaults FALSE — seeding must not publish a half-built catalogue. */
195
+ isLive?: boolean;
196
+ available?: boolean | null;
197
+ images?: string[] | null;
198
+ manufacturer?: string | null;
199
+ /** INTEGER, not text — the column is an integer. */
200
+ modelNumber?: number | null;
201
+ quantity?: number | null;
202
+ type?: string | null;
203
+ variants?: SeedProductVariant[];
204
+ crossVariantTitles?: SeedCrossVariantTitle[];
205
+ };
206
+ export type SeedProductResult = {
207
+ name: string;
208
+ id: string;
209
+ variantCount: number;
210
+ crossVariantCount: number;
211
+ };
212
+ /**
213
+ * Create products, each with its variants and cross-variants.
214
+ *
215
+ * The whole tree goes in ONE request per product, because the route writes it
216
+ * in a transaction — a seed that created a product and then failed partway
217
+ * through its variants would leave a catalogue nobody could trust.
218
+ *
219
+ * Products land unpublished unless `isLive` says otherwise, and are NOT pushed
220
+ * to Stripe: that is a separate deliberate call, because it mints objects in an
221
+ * account the org is billed against.
222
+ */
223
+ export declare function seedProducts(target: SeedTarget, products: readonly SeedProduct[]): Promise<SeedProductResult[]>;
224
+ export type SeedBlogPost = {
225
+ title: string;
226
+ /** Lowercase words separated by single hyphens. Unique per org. */
227
+ slug: string;
228
+ content: string;
229
+ excerpt?: string | null;
230
+ featuredImageUrl?: string | null;
231
+ accessLevel?: "public" | "members" | "subscribers";
232
+ tags?: string[];
233
+ commentResponseType?: "admin" | "all" | "none";
234
+ authorEmail?: string | null;
235
+ categoryId?: string | null;
236
+ /** Defaults FALSE — seeding must not publish drafts to a live blog. */
237
+ publishNow?: boolean;
238
+ };
239
+ export type SeedBlogPostResult = {
240
+ slug: string;
241
+ created: boolean;
242
+ published: boolean;
243
+ message?: string;
244
+ };
245
+ /**
246
+ * Create blog posts.
247
+ *
248
+ * An existing slug is REPORTED rather than thrown, on the same reasoning as
249
+ * coupons: re-running a seed must be safe, and a conflict on the third post
250
+ * must not abandon the remaining seven.
251
+ */
252
+ export declare function seedBlogPosts(target: SeedTarget, posts: readonly SeedBlogPost[]): Promise<SeedBlogPostResult[]>;
253
+ export type SeedCoupon = {
254
+ code: string;
255
+ discountType: "percent" | "amount";
256
+ /** `percent` takes 1–100; `amount` takes a MAJOR-unit amount (10 = $10). */
257
+ value: number;
258
+ validFrom?: Date | string;
259
+ validUntil?: Date | string | null;
260
+ maxUses?: number | null;
261
+ isActive?: boolean;
262
+ duration?: "once" | "forever" | "repeating";
263
+ durationInMonths?: number | null;
264
+ appliesTo?: "order" | "shipping" | "both";
265
+ };
266
+ export type SeedCouponResult = {
267
+ code: string;
268
+ created: boolean;
269
+ /** False when the coupon exists locally but the Stripe mirror failed. */
270
+ stripeSynced: boolean;
271
+ /** Why it was skipped or failed, when it was. */
272
+ message?: string;
273
+ };
274
+ /**
275
+ * Create coupons in the org's own Stripe account as well as locally.
276
+ *
277
+ * An existing code is REPORTED, not treated as a failure: re-running a seed
278
+ * should be safe, and a 409 on the third of ten coupons must not abandon the
279
+ * remaining seven. Anything else still throws — a bad key or a malformed
280
+ * coupon is a real problem and swallowing it would leave a half-seeded store
281
+ * looking successful.
282
+ */
283
+ export declare function seedCoupons(target: SeedTarget, coupons: readonly SeedCoupon[]): Promise<SeedCouponResult[]>;
284
+ /**
285
+ * A whole seed, declared in one object.
286
+ *
287
+ * The shape a `businessdash.seed.ts` exports. Every field is optional so a
288
+ * project can seed only what it has.
289
+ */
290
+ export type SeedDefinition = {
291
+ /** The schema artifact, or a `createSchema(...)` result. */
292
+ dataModel?: DataModelArtifact | {
293
+ toJSONSchema(): DataModelArtifact;
294
+ };
295
+ dataModelOptions?: PushDataModelOptions;
296
+ /** Rows for the custom database, keyed by collection name. */
297
+ records?: SeedRecords;
298
+ /** Static collections to create, each with optional rows. */
299
+ collections?: ReadonlyArray<StaticCollectionDefinition & {
300
+ rows?: ReadonlyArray<{
301
+ rowId?: string;
302
+ data: Record<string, unknown>;
303
+ }>;
304
+ }>;
305
+ /** Products, each with its variants and cross-variants. */
306
+ products?: readonly SeedProduct[];
307
+ posts?: readonly SeedBlogPost[];
308
+ coupons?: readonly SeedCoupon[];
309
+ };
310
+ export type SeedRunResult = {
311
+ dataModel?: PushDataModelResult;
312
+ records?: SeedRecordsResult;
313
+ collections?: Array<{
314
+ slug: string;
315
+ rowsWritten: number;
316
+ }>;
317
+ products?: SeedProductResult[];
318
+ posts?: SeedBlogPostResult[];
319
+ coupons?: SeedCouponResult[];
320
+ };
321
+ export type RunSeedOptions = {
322
+ /** Called with human-readable progress. Wire it to your build's logger. */
323
+ onProgress?: (message: string) => void;
324
+ /**
325
+ * Refuse to push a schema whose plan contains destructive or exposing
326
+ * changes. Defaults to TRUE, because the common case for this function is
327
+ * an automated deploy, and an automated deploy should not be the thing that
328
+ * drops a customer's column.
329
+ */
330
+ failOnDangerousPlan?: boolean;
331
+ };
332
+ /**
333
+ * Run a whole seed, in dependency order: schema first, then the records that
334
+ * depend on it, then static collections, then products, posts and coupons.
335
+ *
336
+ * Order matters and is not configurable — seeding records into a collection
337
+ * whose schema has not been promoted yet fails in a way that reads as a
338
+ * permissions problem.
339
+ */
340
+ export declare function runSeed(target: SeedTarget, seed: SeedDefinition, options?: RunSeedOptions): Promise<SeedRunResult>;
341
+ /**
342
+ * Read a seed target from environment variables.
343
+ *
344
+ * The names match what the CLI already reads, so a project that has the CLI
345
+ * working needs no new configuration to call these functions from a build step.
346
+ */
347
+ export declare function seedTargetFromEnv(env?: Record<string, string | undefined>): SeedTarget;
348
+ /**
349
+ * Type-only helper for a `businessdash.seed.ts`, so a config file gets
350
+ * completion and checking without importing anything at runtime.
351
+ */
352
+ export declare function defineSeed(seed: SeedDefinition): SeedDefinition;
353
+ export type { CollectionDefinition };
354
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/seed-core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAEpE,gDAAgD;AAChD,MAAM,MAAM,UAAU,GAAG;IACxB,yEAAyE;IACzE,MAAM,EAAE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