bitsnap-payloadcms 0.0.0-stage → 0.1.1

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 (56) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +270 -2
  3. package/dist/client.d.ts +3 -0
  4. package/dist/client.js +5 -0
  5. package/dist/client.js.map +1 -0
  6. package/dist/constants.d.ts +7 -0
  7. package/dist/constants.js +8 -0
  8. package/dist/constants.js.map +1 -0
  9. package/dist/fields/getFields.d.ts +54 -0
  10. package/dist/fields/getFields.js +150 -0
  11. package/dist/fields/getFields.js.map +1 -0
  12. package/dist/fields/index.d.ts +2 -0
  13. package/dist/fields/index.js +3 -0
  14. package/dist/fields/index.js.map +1 -0
  15. package/dist/index.d.ts +7 -0
  16. package/dist/index.js +6 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/plugin.d.ts +15 -0
  19. package/dist/plugin.js +60 -0
  20. package/dist/plugin.js.map +1 -0
  21. package/dist/server/client.d.ts +47 -0
  22. package/dist/server/client.js +68 -0
  23. package/dist/server/client.js.map +1 -0
  24. package/dist/server/endpoints.d.ts +9 -0
  25. package/dist/server/endpoints.js +190 -0
  26. package/dist/server/endpoints.js.map +1 -0
  27. package/dist/server/errors.d.ts +9 -0
  28. package/dist/server/errors.js +35 -0
  29. package/dist/server/errors.js.map +1 -0
  30. package/dist/server/index.d.ts +6 -0
  31. package/dist/server/index.js +6 -0
  32. package/dist/server/index.js.map +1 -0
  33. package/dist/server/schemas.d.ts +55 -0
  34. package/dist/server/schemas.js +46 -0
  35. package/dist/server/schemas.js.map +1 -0
  36. package/dist/types.d.ts +75 -0
  37. package/dist/types.js +3 -0
  38. package/dist/types.js.map +1 -0
  39. package/dist/ui/BitsnapManager.css +159 -0
  40. package/dist/ui/BitsnapManager.d.ts +5 -0
  41. package/dist/ui/BitsnapManager.js +642 -0
  42. package/dist/ui/BitsnapManager.js.map +1 -0
  43. package/dist/ui/LinkToDoc.d.ts +4 -0
  44. package/dist/ui/LinkToDoc.js +48 -0
  45. package/dist/ui/LinkToDoc.js.map +1 -0
  46. package/dist/ui/ProductSelect.css +199 -0
  47. package/dist/ui/ProductSelect.d.ts +5 -0
  48. package/dist/ui/ProductSelect.js +146 -0
  49. package/dist/ui/ProductSelect.js.map +1 -0
  50. package/dist/ui/getBitsnapClientConfig.d.ts +13 -0
  51. package/dist/ui/getBitsnapClientConfig.js +30 -0
  52. package/dist/ui/getBitsnapClientConfig.js.map +1 -0
  53. package/dist/utils/formatCurrency.d.ts +6 -0
  54. package/dist/utils/formatCurrency.js +24 -0
  55. package/dist/utils/formatCurrency.js.map +1 -0
  56. package/package.json +93 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Piotr Michalik
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,271 @@
1
- # Temporary Holding Version
1
+ # bitsnap-payloadcms
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Bitsnap plugin for [Payload CMS 3](https://payloadcms.com) — product sync, an admin product
4
+ manager and a product picker for Payload-based storefronts.
5
+
6
+ The plugin adds:
7
+
8
+ - **Bitsnap fields** (`bitsnapID`, `skipSync`, `docUrl`) to the collections you list in `sync`.
9
+ - **Admin components** — a product manager (`BitsnapManager`), a "show in Bitsnap" link
10
+ (`LinkToDoc`) and a product picker (`ProductSelect`) that all live in the Payload admin.
11
+ - **REST endpoints** that proxy the Bitsnap product API so the admin UI never needs the
12
+ Bitsnap API key.
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ pnpm add bitsnap-payloadcms
18
+ # or
19
+ npm install bitsnap-payloadcms
20
+ ```
21
+
22
+ > **Not on npm yet?** Install the published tarball from the GitHub release:
23
+ >
24
+ > ```bash
25
+ > pnpm add https://github.com/emmems/bitsnap-payloadcms/releases/download/v0.1.1/bitsnap-payloadcms-0.1.1.tgz
26
+ > ```
27
+
28
+ ### 1. Register the plugin
29
+
30
+ ```ts
31
+ // src/payload.config.ts
32
+ import { bitsnapPlugin } from 'bitsnap-payloadcms'
33
+ import { buildConfig } from 'payload'
34
+
35
+ export default buildConfig({
36
+ // ...
37
+ plugins: [
38
+ bitsnapPlugin({
39
+ bitsnapApiKey: process.env.BITSNAP_API_KEY ?? '',
40
+ projectId: process.env.BITSNAP_PROJECT_ID ?? '',
41
+ currency: 'PLN',
42
+ sync: [
43
+ { collection: 'products', fields: [] },
44
+ ],
45
+ }),
46
+ ],
47
+ })
48
+ ```
49
+
50
+ ### 2. Regenerate the Payload artefacts — mandatory
51
+
52
+ The plugin injects fields **and** admin components, so Payload has to pick them up:
53
+
54
+ ```bash
55
+ pnpm generate:importmap # required — resolves the admin components
56
+ pnpm generate:types # required — refreshes the generated types
57
+ ```
58
+
59
+ > `generate:importmap` is what maps `bitsnap-payloadcms/client#BitsnapManager` (and the other
60
+ > admin components) to real modules. Without it the admin panel renders the default field
61
+ > instead of the Bitsnap components.
62
+
63
+ **No `next.config.js` changes are needed.** The plugin is plain Payload config — no
64
+ transpilePackages, no webpack/turbopack tweaks, no `server-only` imports.
65
+
66
+ ## Configuration
67
+
68
+ | Option | Type | Default | Description |
69
+ | -------------- | ----------------------------- | -------------------------- | ------------------------------------------------------------------ |
70
+ | `bitsnapApiKey` | `string` | — | Bitsnap API key. Server-side only — it never reaches the browser. |
71
+ | `projectId` | `string` | `process.env.BITSNAP_PROJECT_ID` | Bitsnap project the products belong to. |
72
+ | `dashboardUrl` | `string` | `https://bitsnap.pl` | Base URL of the Bitsnap dashboard. |
73
+ | `apiBasePath` | `string` | `/bitsnap` | Path the REST endpoints are mounted on, relative to the API root. |
74
+ | `currency` | `string` | `PLN` | Currency used when creating products and variants. |
75
+ | `logs` | `boolean` | `false` | Reserved for future use — no behaviour today. |
76
+ | `sync` | `SyncConfig[]` | `[]` | Collections that receive the Bitsnap fields. The `fields` mapping is reserved for future use. |
77
+ | `webhooks` | `BitsnapWebhookHandler \| BitsnapWebhookHandlers` | — | Reserved for future use — no behaviour today. |
78
+
79
+ The endpoints are served relative to Payload's API root (`config.routes.api`, `/api` by default),
80
+ so the default configuration exposes them at `/api/bitsnap/...`.
81
+
82
+ ### Environment variables
83
+
84
+ | Variable | Used for |
85
+ | ---------------------- | --------------------------------------------------------------- |
86
+ | `BITSNAP_API_KEY` | Fallback API key when `bitsnapApiKey` is not set explicitly. |
87
+ | `BITSNAP_PROJECT_ID` | Fallback project id when `projectId` is not set explicitly. |
88
+ | `CUSTOM_BITSNAP_HOST` | Points the Bitsnap SDK at a self-hosted Bitsnap instance. |
89
+
90
+ ## Field helpers
91
+
92
+ ### `bitsnapManagerField(pluginConfig?, overrides?, apiRoute?)`
93
+
94
+ A `ui` field that renders the Bitsnap product manager. Add it to the collection that holds
95
+ your products:
96
+
97
+ ```ts
98
+ import { bitsnapManagerField } from 'bitsnap-payloadcms'
99
+
100
+ export const Products: CollectionConfig = {
101
+ slug: 'products',
102
+ fields: [
103
+ { name: 'title', type: 'text' },
104
+ bitsnapManagerField(),
105
+ ],
106
+ }
107
+ ```
108
+
109
+ ### `productSelectField(pluginConfig?, overrides?, apiRoute?)`
110
+
111
+ A text field that renders the Bitsnap product picker. Use it in blocks that display a single
112
+ product:
113
+
114
+ ```ts
115
+ import { productSelectField } from 'bitsnap-payloadcms'
116
+
117
+ export const ProductDetails: Block = {
118
+ slug: 'productDetails',
119
+ fields: [productSelectField()],
120
+ }
121
+ ```
122
+
123
+ Both helpers take the plugin configuration as their first argument so the admin components
124
+ receive the same `projectId`, `dashboardUrl` and `currency` the plugin uses:
125
+
126
+ ```ts
127
+ import { bitsnapPluginConfig } from '@/logic/bitsnap'
128
+
129
+ fields: [bitsnapManagerField(bitsnapPluginConfig)]
130
+ ```
131
+
132
+ `apiRoute` is only needed when the project changed Payload's `config.routes.api` — it defaults
133
+ to `/api`.
134
+
135
+ ### `bitsnapClientConfig(pluginConfig?, apiRoute?)`
136
+
137
+ Maps a plugin configuration onto the values the admin components receive through
138
+ `clientProps` (`projectId`, `dashboardUrl`, `currency`, `apiBaseUrl`). Use it when you build
139
+ your own admin component and want the same configuration the plugin uses:
140
+
141
+ ```ts
142
+ import { bitsnapClientConfig } from 'bitsnap-payloadcms'
143
+
144
+ const clientConfig = bitsnapClientConfig({ projectId: 'kL' })
145
+ // { apiBaseUrl: '/api/bitsnap', currency: 'PLN', dashboardUrl: 'https://bitsnap.pl', projectId: 'kL' }
146
+ ```
147
+
148
+ ## REST endpoints
149
+
150
+ All endpoints require an authenticated Payload user and answer with `401` and
151
+ `{ "error": "Brak autoryzacji" }` otherwise.
152
+
153
+ | Method | Path | Description | Body / response |
154
+ | ------ | ----------------------------- | ---------------------------------------------- | ---------------------------------------------------- |
155
+ | `POST` | `/api/bitsnap/products` | Creates a managed product in Bitsnap. | body → `{ id, revision }` |
156
+ | `GET` | `/api/bitsnap/products/:id` | Reads a managed product (incl. its revision). | response → `{ product }` |
157
+ | `PATCH`| `/api/bitsnap/products/:id` | Patches a managed product in Bitsnap. | body → `{ id, revision }` |
158
+ | `GET` | `/api/bitsnap/shop-products` | Lists the products of the project. | response → the raw Bitsnap envelope, unchanged |
159
+
160
+ Request bodies are validated with zod. Invalid bodies answer with `400` and
161
+ `{ "error": "Nieprawidłowe dane żądania" }`.
162
+
163
+ `POST /api/bitsnap/products`:
164
+
165
+ ```json
166
+ {
167
+ "name": "Krem nawilżający",
168
+ "priceAmount": 4999,
169
+ "priceCurrency": "PLN",
170
+ "status": "PUBLISHED",
171
+ "availableQuantity": 12,
172
+ "variants": [{ "name": "50 ml", "priceAmount": 4999 }]
173
+ }
174
+ ```
175
+
176
+ `priceAmount` and `availableQuantity` are integer minor units (grosze/cents) and must not be
177
+ negative. `priceCurrency` defaults to the currency the plugin was configured with.
178
+
179
+ `PATCH /api/bitsnap/products/:id` accepts `revision`, `name`, `priceAmount`, `status`,
180
+ `availableQuantity` and `variants`. Pass the `revision` you last read to get optimistic
181
+ concurrency — a mismatch answers with `409` and
182
+ `{ "error": "Produkt zmienił się w Bitsnapie — kliknij Odśwież" }`.
183
+
184
+ ## Server helpers
185
+
186
+ The server-side helpers are exported as well, so you can build your own routes or jobs:
187
+
188
+ ```ts
189
+ import {
190
+ configureBitsnapBackend,
191
+ createManagedProduct,
192
+ getManagedProduct,
193
+ getShopProducts,
194
+ updateManagedProduct,
195
+ } from 'bitsnap-payloadcms'
196
+
197
+ configureBitsnapBackend({ apiKey: process.env.BITSNAP_API_KEY })
198
+
199
+ const product = await getManagedProduct('kL', 'product-id')
200
+ const created = await createManagedProduct('kL', { name: 'Krem', priceAmount: 4999, priceCurrency: 'PLN' })
201
+ const updated = await updateManagedProduct('kL', 'product-id', { priceAmount: 5999 })
202
+ const list = await getShopProducts('kL')
203
+ ```
204
+
205
+ The zod schemas used by the endpoints are exported too: `bitsnapStatusSchema`,
206
+ `bitsnapVariantSchema`, `bitsnapCreateSchema` and `bitsnapUpdateSchema`.
207
+
208
+ ## Migrating from the in-repo plugin
209
+
210
+ If the plugin used to live inside your application (for example
211
+ `src/plugins/plugin-bitsnap/`), you can drop the local copy and use the published package:
212
+
213
+ 1. Delete the local plugin folder and its UI components.
214
+ 2. Replace the import in `src/payload.config.ts`:
215
+
216
+ ```diff
217
+ - import { bitsnapPlugin } from '@/plugins/plugin-bitsnap/admin'
218
+ + import { bitsnapPlugin } from 'bitsnap-payloadcms'
219
+ ```
220
+
221
+ 3. Replace the local field imports — both helpers are **functions**, so call them with the
222
+ shared plugin configuration:
223
+
224
+ ```diff
225
+ - import { bitsnapManagerField } from '@/plugins/plugin-bitsnap/fields/getFields'
226
+ + import { bitsnapManagerField } from 'bitsnap-payloadcms'
227
+ ```
228
+
229
+ ```diff
230
+ - import { productSelectField } from '@/blocks/_shared/productSelectField'
231
+ + import { productSelectField } from 'bitsnap-payloadcms'
232
+ ```
233
+
234
+ ```diff
235
+ - fields: [bitsnapManagerField],
236
+ + fields: [bitsnapManagerField(bitsnapPluginConfig)],
237
+ ```
238
+
239
+ ```diff
240
+ - export const productSelectField: Field = { name: 'productID', type: 'text', ... }
241
+ + export const productSelectField: Field = productSelectField(bitsnapPluginConfig)
242
+ ```
243
+
244
+ 4. Delete the local API routes under `src/app/api/admin/bitsnap/` — the plugin now registers
245
+ the same endpoints through `config.endpoints`:
246
+
247
+ | Old route | New endpoint |
248
+ | ----------------------------------------------------- | ----------------------- |
249
+ | `POST /api/admin/bitsnap/products` | `POST /api/bitsnap/products` |
250
+ | `GET /api/admin/bitsnap/products/:id` | `GET /api/bitsnap/products/:id` |
251
+ | `PATCH /api/admin/bitsnap/products/:id` | `PATCH /api/bitsnap/products/:id` |
252
+ | `GET /api/admin/bitsnap/shop-products` | `GET /api/bitsnap/shop-products` |
253
+
254
+ The admin components call the new paths, so no other change is needed.
255
+
256
+ 5. Run `pnpm generate:importmap` and `pnpm generate:types`.
257
+
258
+ ## Publishing
259
+
260
+ Releases are published to npm by GitHub Actions:
261
+
262
+ 1. Create an npm token with **publish** scope (an automation token or a granular token with the
263
+ `read-package` + `write-package` permissions).
264
+ 2. Add it to the repository as a secret named **`NPM_TOKEN`**.
265
+ 3. Publish by creating a GitHub release — or by running the `Publish` workflow manually.
266
+
267
+ The workflow runs `pnpm build`, then `npm publish --provenance --access public`.
268
+
269
+ ## License
270
+
271
+ MIT © Piotr Michalik
@@ -0,0 +1,3 @@
1
+ export { BitsnapManager } from './ui/BitsnapManager.js';
2
+ export { LinkToDoc } from './ui/LinkToDoc.js';
3
+ export { ProductSelect } from './ui/ProductSelect.js';
package/dist/client.js ADDED
@@ -0,0 +1,5 @@
1
+ export { BitsnapManager } from './ui/BitsnapManager.js';
2
+ export { LinkToDoc } from './ui/LinkToDoc.js';
3
+ export { ProductSelect } from './ui/ProductSelect.js';
4
+
5
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/client.ts"],"sourcesContent":["export { BitsnapManager } from './ui/BitsnapManager.js'\nexport { LinkToDoc } from './ui/LinkToDoc.js'\nexport { ProductSelect } from './ui/ProductSelect.js'\n"],"names":["BitsnapManager","LinkToDoc","ProductSelect"],"mappings":"AAAA,SAASA,cAAc,QAAQ,yBAAwB;AACvD,SAASC,SAAS,QAAQ,oBAAmB;AAC7C,SAASC,aAAa,QAAQ,wBAAuB"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Default values used when the consumer does not override them.
3
+ */
4
+ export declare const DEFAULT_DASHBOARD_URL = "https://bitsnap.pl";
5
+ export declare const DEFAULT_API_BASE_PATH = "/bitsnap";
6
+ export declare const DEFAULT_CURRENCY = "PLN";
7
+ export declare const DEFAULT_PRODUCTS_LIMIT = 200;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Default values used when the consumer does not override them.
3
+ */ export const DEFAULT_DASHBOARD_URL = 'https://bitsnap.pl';
4
+ export const DEFAULT_API_BASE_PATH = '/bitsnap';
5
+ export const DEFAULT_CURRENCY = 'PLN';
6
+ export const DEFAULT_PRODUCTS_LIMIT = 200;
7
+
8
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/constants.ts"],"sourcesContent":["/**\n * Default values used when the consumer does not override them.\n */\nexport const DEFAULT_DASHBOARD_URL = 'https://bitsnap.pl'\n\nexport const DEFAULT_API_BASE_PATH = '/bitsnap'\n\nexport const DEFAULT_CURRENCY = 'PLN'\n\nexport const DEFAULT_PRODUCTS_LIMIT = 200\n"],"names":["DEFAULT_DASHBOARD_URL","DEFAULT_API_BASE_PATH","DEFAULT_CURRENCY","DEFAULT_PRODUCTS_LIMIT"],"mappings":"AAAA;;CAEC,GACD,OAAO,MAAMA,wBAAwB,qBAAoB;AAEzD,OAAO,MAAMC,wBAAwB,WAAU;AAE/C,OAAO,MAAMC,mBAAmB,MAAK;AAErC,OAAO,MAAMC,yBAAyB,IAAG"}
@@ -0,0 +1,54 @@
1
+ import type { CollectionConfig, Field } from 'payload';
2
+ import type { BitsnapClientConfig, BitsnapPluginConfig, SanitizedBitsnapPluginConfig, SyncConfig } from '../types.js';
3
+ /**
4
+ * Import-map paths of the admin components shipped with this package.
5
+ *
6
+ * Payload resolves these strings through the generated import map, so the
7
+ * consumer has to run `payload generate:importmap` after installing the plugin.
8
+ */
9
+ export declare const BITSNAP_MANAGER_COMPONENT_PATH = "bitsnap-payloadcms/client#BitsnapManager";
10
+ export declare const BITSNAP_LINK_TO_DOC_COMPONENT_PATH = "bitsnap-payloadcms/client#LinkToDoc";
11
+ export declare const BITSNAP_PRODUCT_SELECT_COMPONENT_PATH = "bitsnap-payloadcms/client#ProductSelect";
12
+ /**
13
+ * Default Payload REST API root. Mirrors Payload's own `config.routes.api` default.
14
+ */
15
+ export declare const DEFAULT_API_ROUTE = "/api";
16
+ export type GetFieldsArgs = {
17
+ /**
18
+ * Payload REST API root, e.g. `/api`. Used to build the absolute path of the
19
+ * plugin endpoints that the admin components call.
20
+ */
21
+ apiRoute?: string;
22
+ collection: CollectionConfig;
23
+ pluginConfig: SanitizedBitsnapPluginConfig;
24
+ syncConfig: SyncConfig;
25
+ };
26
+ /**
27
+ * Maps a plugin configuration onto the values the admin components need.
28
+ *
29
+ * Only non-secret values end up here — the API key is never part of the
30
+ * client configuration.
31
+ */
32
+ export declare function bitsnapClientConfig(pluginConfig?: Partial<BitsnapPluginConfig>, apiRoute?: string): BitsnapClientConfig;
33
+ /**
34
+ * `ui` field that renders the Bitsnap product manager inside the Payload admin.
35
+ *
36
+ * `apiRoute` is only needed when the consuming project changed Payload's
37
+ * `config.routes.api` — it defaults to `/api`.
38
+ */
39
+ export declare function bitsnapManagerField(pluginConfig?: Partial<BitsnapPluginConfig>, overrides?: Partial<Field>, apiRoute?: string): Field;
40
+ /**
41
+ * Text field that renders the Bitsnap product picker. Meant for blocks that
42
+ * display a single Bitsnap product.
43
+ *
44
+ * `apiRoute` is only needed when the consuming project changed Payload's
45
+ * `config.routes.api` — it defaults to `/api`.
46
+ */
47
+ export declare function productSelectField(pluginConfig?: Partial<BitsnapPluginConfig>, overrides?: Partial<Field>, apiRoute?: string): Field;
48
+ /**
49
+ * Fields the plugin appends to every collection listed in `sync`.
50
+ *
51
+ * The collection's own fields are never replaced — the Bitsnap fields are
52
+ * appended so the collection keeps its own schema intact.
53
+ */
54
+ export declare function getFields({ apiRoute, collection, pluginConfig, syncConfig, }: GetFieldsArgs): Field[];
@@ -0,0 +1,150 @@
1
+ import { DEFAULT_API_BASE_PATH, DEFAULT_CURRENCY, DEFAULT_DASHBOARD_URL } from '../constants.js';
2
+ /**
3
+ * Import-map paths of the admin components shipped with this package.
4
+ *
5
+ * Payload resolves these strings through the generated import map, so the
6
+ * consumer has to run `payload generate:importmap` after installing the plugin.
7
+ */ export const BITSNAP_MANAGER_COMPONENT_PATH = 'bitsnap-payloadcms/client#BitsnapManager';
8
+ export const BITSNAP_LINK_TO_DOC_COMPONENT_PATH = 'bitsnap-payloadcms/client#LinkToDoc';
9
+ export const BITSNAP_PRODUCT_SELECT_COMPONENT_PATH = 'bitsnap-payloadcms/client#ProductSelect';
10
+ /**
11
+ * Default Payload REST API root. Mirrors Payload's own `config.routes.api` default.
12
+ */ export const DEFAULT_API_ROUTE = '/api';
13
+ /**
14
+ * Maps a plugin configuration onto the values the admin components need.
15
+ *
16
+ * Only non-secret values end up here — the API key is never part of the
17
+ * client configuration.
18
+ */ export function bitsnapClientConfig(pluginConfig, apiRoute = DEFAULT_API_ROUTE) {
19
+ const apiBasePath = pluginConfig?.apiBasePath ?? DEFAULT_API_BASE_PATH;
20
+ const currency = pluginConfig?.currency ?? DEFAULT_CURRENCY;
21
+ const dashboardUrl = pluginConfig?.dashboardUrl ?? DEFAULT_DASHBOARD_URL;
22
+ const projectId = pluginConfig?.projectId ?? process.env.BITSNAP_PROJECT_ID ?? '';
23
+ const normalizedApiRoute = apiRoute.endsWith('/') ? apiRoute.slice(0, -1) : apiRoute;
24
+ return {
25
+ apiBaseUrl: `${normalizedApiRoute}${apiBasePath}`,
26
+ currency,
27
+ dashboardUrl,
28
+ projectId
29
+ };
30
+ }
31
+ /**
32
+ * `ui` field that renders the Bitsnap product manager inside the Payload admin.
33
+ *
34
+ * `apiRoute` is only needed when the consuming project changed Payload's
35
+ * `config.routes.api` — it defaults to `/api`.
36
+ */ export function bitsnapManagerField(pluginConfig, overrides, apiRoute) {
37
+ const field = {
38
+ name: 'bitsnapManager',
39
+ type: 'ui',
40
+ label: {
41
+ en: 'Product in Bitsnap',
42
+ pl: 'Produkt w Bitsnap'
43
+ },
44
+ admin: {
45
+ components: {
46
+ Field: {
47
+ path: BITSNAP_MANAGER_COMPONENT_PATH,
48
+ clientProps: bitsnapClientConfig(pluginConfig, apiRoute)
49
+ }
50
+ }
51
+ }
52
+ };
53
+ return applyOverrides(field, overrides);
54
+ }
55
+ /**
56
+ * Text field that renders the Bitsnap product picker. Meant for blocks that
57
+ * display a single Bitsnap product.
58
+ *
59
+ * `apiRoute` is only needed when the consuming project changed Payload's
60
+ * `config.routes.api` — it defaults to `/api`.
61
+ */ export function productSelectField(pluginConfig, overrides, apiRoute) {
62
+ const field = {
63
+ name: 'productID',
64
+ type: 'text',
65
+ label: {
66
+ en: 'Product',
67
+ pl: 'Produkt'
68
+ },
69
+ admin: {
70
+ components: {
71
+ Field: {
72
+ path: BITSNAP_PRODUCT_SELECT_COMPONENT_PATH,
73
+ clientProps: bitsnapClientConfig(pluginConfig, apiRoute)
74
+ }
75
+ },
76
+ description: {
77
+ en: 'Bitsnap product shown by this block.',
78
+ pl: 'Produkt Bitsnap wyświetlany w tym bloku.'
79
+ },
80
+ readOnly: false
81
+ },
82
+ required: false
83
+ };
84
+ return applyOverrides(field, overrides);
85
+ }
86
+ /**
87
+ * Fields the plugin appends to every collection listed in `sync`.
88
+ *
89
+ * The collection's own fields are never replaced — the Bitsnap fields are
90
+ * appended so the collection keeps its own schema intact.
91
+ */ export function getFields({ apiRoute, collection, pluginConfig, syncConfig }) {
92
+ const bitsnapIDField = {
93
+ name: 'bitsnapID',
94
+ type: 'text',
95
+ admin: {
96
+ position: 'sidebar',
97
+ readOnly: true
98
+ },
99
+ label: {
100
+ en: 'Bitsnap Product Id',
101
+ pl: 'ID produktu Bitsnap'
102
+ },
103
+ saveToJWT: true
104
+ };
105
+ const skipSyncField = {
106
+ name: 'skipSync',
107
+ type: 'checkbox',
108
+ admin: {
109
+ position: 'sidebar',
110
+ readOnly: true
111
+ },
112
+ label: {
113
+ en: 'Skip Sync',
114
+ pl: 'Pomiń synchronizację'
115
+ }
116
+ };
117
+ const docUrlField = {
118
+ name: 'docUrl',
119
+ type: 'ui',
120
+ admin: {
121
+ components: {
122
+ Field: {
123
+ path: BITSNAP_LINK_TO_DOC_COMPONENT_PATH,
124
+ clientProps: bitsnapClientConfig(pluginConfig, apiRoute)
125
+ }
126
+ },
127
+ custom: {
128
+ nameOfIDField: 'bitsnapID'
129
+ },
130
+ position: 'sidebar'
131
+ }
132
+ };
133
+ // The sync mapping itself is applied by the sync job — the plugin only adds
134
+ // the fields the admin UI needs.
135
+ void syncConfig;
136
+ return [
137
+ ...collection.fields,
138
+ bitsnapIDField,
139
+ skipSyncField,
140
+ docUrlField
141
+ ];
142
+ }
143
+ function applyOverrides(field, overrides) {
144
+ if (!overrides) {
145
+ return field;
146
+ }
147
+ return Object.assign(field, overrides);
148
+ }
149
+
150
+ //# sourceMappingURL=getFields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/fields/getFields.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nimport {\n DEFAULT_API_BASE_PATH,\n DEFAULT_CURRENCY,\n DEFAULT_DASHBOARD_URL,\n} from '../constants.js'\nimport type {\n BitsnapClientConfig,\n BitsnapPluginConfig,\n SanitizedBitsnapPluginConfig,\n SyncConfig,\n} from '../types.js'\n\n/**\n * Import-map paths of the admin components shipped with this package.\n *\n * Payload resolves these strings through the generated import map, so the\n * consumer has to run `payload generate:importmap` after installing the plugin.\n */\nexport const BITSNAP_MANAGER_COMPONENT_PATH = 'bitsnap-payloadcms/client#BitsnapManager'\nexport const BITSNAP_LINK_TO_DOC_COMPONENT_PATH = 'bitsnap-payloadcms/client#LinkToDoc'\nexport const BITSNAP_PRODUCT_SELECT_COMPONENT_PATH = 'bitsnap-payloadcms/client#ProductSelect'\n\n/**\n * Default Payload REST API root. Mirrors Payload's own `config.routes.api` default.\n */\nexport const DEFAULT_API_ROUTE = '/api'\n\nexport type GetFieldsArgs = {\n /**\n * Payload REST API root, e.g. `/api`. Used to build the absolute path of the\n * plugin endpoints that the admin components call.\n */\n apiRoute?: string\n collection: CollectionConfig\n pluginConfig: SanitizedBitsnapPluginConfig\n syncConfig: SyncConfig\n}\n\n/**\n * Maps a plugin configuration onto the values the admin components need.\n *\n * Only non-secret values end up here — the API key is never part of the\n * client configuration.\n */\nexport function bitsnapClientConfig(\n pluginConfig?: Partial<BitsnapPluginConfig>,\n apiRoute: string = DEFAULT_API_ROUTE,\n): BitsnapClientConfig {\n const apiBasePath = pluginConfig?.apiBasePath ?? DEFAULT_API_BASE_PATH\n const currency = pluginConfig?.currency ?? DEFAULT_CURRENCY\n const dashboardUrl = pluginConfig?.dashboardUrl ?? DEFAULT_DASHBOARD_URL\n const projectId = pluginConfig?.projectId ?? process.env.BITSNAP_PROJECT_ID ?? ''\n const normalizedApiRoute = apiRoute.endsWith('/') ? apiRoute.slice(0, -1) : apiRoute\n\n return {\n apiBaseUrl: `${normalizedApiRoute}${apiBasePath}`,\n currency,\n dashboardUrl,\n projectId,\n }\n}\n\n/**\n * `ui` field that renders the Bitsnap product manager inside the Payload admin.\n *\n * `apiRoute` is only needed when the consuming project changed Payload's\n * `config.routes.api` — it defaults to `/api`.\n */\nexport function bitsnapManagerField(\n pluginConfig?: Partial<BitsnapPluginConfig>,\n overrides?: Partial<Field>,\n apiRoute?: string,\n): Field {\n const field: Field = {\n name: 'bitsnapManager',\n type: 'ui',\n label: { en: 'Product in Bitsnap', pl: 'Produkt w Bitsnap' },\n admin: {\n components: {\n Field: {\n path: BITSNAP_MANAGER_COMPONENT_PATH,\n clientProps: bitsnapClientConfig(pluginConfig, apiRoute),\n },\n },\n },\n }\n\n return applyOverrides(field, overrides)\n}\n\n/**\n * Text field that renders the Bitsnap product picker. Meant for blocks that\n * display a single Bitsnap product.\n *\n * `apiRoute` is only needed when the consuming project changed Payload's\n * `config.routes.api` — it defaults to `/api`.\n */\nexport function productSelectField(\n pluginConfig?: Partial<BitsnapPluginConfig>,\n overrides?: Partial<Field>,\n apiRoute?: string,\n): Field {\n const field: Field = {\n name: 'productID',\n type: 'text',\n label: { en: 'Product', pl: 'Produkt' },\n admin: {\n components: {\n Field: {\n path: BITSNAP_PRODUCT_SELECT_COMPONENT_PATH,\n clientProps: bitsnapClientConfig(pluginConfig, apiRoute),\n },\n },\n description: {\n en: 'Bitsnap product shown by this block.',\n pl: 'Produkt Bitsnap wyświetlany w tym bloku.',\n },\n readOnly: false,\n },\n required: false,\n }\n\n return applyOverrides(field, overrides)\n}\n\n/**\n * Fields the plugin appends to every collection listed in `sync`.\n *\n * The collection's own fields are never replaced — the Bitsnap fields are\n * appended so the collection keeps its own schema intact.\n */\nexport function getFields({\n apiRoute,\n collection,\n pluginConfig,\n syncConfig,\n}: GetFieldsArgs): Field[] {\n const bitsnapIDField: Field = {\n name: 'bitsnapID',\n type: 'text',\n admin: {\n position: 'sidebar',\n readOnly: true,\n },\n label: { en: 'Bitsnap Product Id', pl: 'ID produktu Bitsnap' },\n saveToJWT: true,\n }\n\n const skipSyncField: Field = {\n name: 'skipSync',\n type: 'checkbox',\n admin: {\n position: 'sidebar',\n readOnly: true,\n },\n label: { en: 'Skip Sync', pl: 'Pomiń synchronizację' },\n }\n\n const docUrlField: Field = {\n name: 'docUrl',\n type: 'ui',\n admin: {\n components: {\n Field: {\n path: BITSNAP_LINK_TO_DOC_COMPONENT_PATH,\n clientProps: bitsnapClientConfig(pluginConfig, apiRoute),\n },\n },\n custom: {\n nameOfIDField: 'bitsnapID',\n },\n position: 'sidebar',\n },\n }\n\n // The sync mapping itself is applied by the sync job — the plugin only adds\n // the fields the admin UI needs.\n void syncConfig\n\n return [...collection.fields, bitsnapIDField, skipSyncField, docUrlField]\n}\n\nfunction applyOverrides(field: Field, overrides?: Partial<Field>): Field {\n if (!overrides) {\n return field\n }\n\n return Object.assign(field, overrides)\n}\n"],"names":["DEFAULT_API_BASE_PATH","DEFAULT_CURRENCY","DEFAULT_DASHBOARD_URL","BITSNAP_MANAGER_COMPONENT_PATH","BITSNAP_LINK_TO_DOC_COMPONENT_PATH","BITSNAP_PRODUCT_SELECT_COMPONENT_PATH","DEFAULT_API_ROUTE","bitsnapClientConfig","pluginConfig","apiRoute","apiBasePath","currency","dashboardUrl","projectId","process","env","BITSNAP_PROJECT_ID","normalizedApiRoute","endsWith","slice","apiBaseUrl","bitsnapManagerField","overrides","field","name","type","label","en","pl","admin","components","Field","path","clientProps","applyOverrides","productSelectField","description","readOnly","required","getFields","collection","syncConfig","bitsnapIDField","position","saveToJWT","skipSyncField","docUrlField","custom","nameOfIDField","fields","Object","assign"],"mappings":"AAEA,SACEA,qBAAqB,EACrBC,gBAAgB,EAChBC,qBAAqB,QAChB,kBAAiB;AAQxB;;;;;CAKC,GACD,OAAO,MAAMC,iCAAiC,2CAA0C;AACxF,OAAO,MAAMC,qCAAqC,sCAAqC;AACvF,OAAO,MAAMC,wCAAwC,0CAAyC;AAE9F;;CAEC,GACD,OAAO,MAAMC,oBAAoB,OAAM;AAavC;;;;;CAKC,GACD,OAAO,SAASC,oBACdC,YAA2C,EAC3CC,WAAmBH,iBAAiB;IAEpC,MAAMI,cAAcF,cAAcE,eAAeV;IACjD,MAAMW,WAAWH,cAAcG,YAAYV;IAC3C,MAAMW,eAAeJ,cAAcI,gBAAgBV;IACnD,MAAMW,YAAYL,cAAcK,aAAaC,QAAQC,GAAG,CAACC,kBAAkB,IAAI;IAC/E,MAAMC,qBAAqBR,SAASS,QAAQ,CAAC,OAAOT,SAASU,KAAK,CAAC,GAAG,CAAC,KAAKV;IAE5E,OAAO;QACLW,YAAY,GAAGH,qBAAqBP,aAAa;QACjDC;QACAC;QACAC;IACF;AACF;AAEA;;;;;CAKC,GACD,OAAO,SAASQ,oBACdb,YAA2C,EAC3Cc,SAA0B,EAC1Bb,QAAiB;IAEjB,MAAMc,QAAe;QACnBC,MAAM;QACNC,MAAM;QACNC,OAAO;YAAEC,IAAI;YAAsBC,IAAI;QAAoB;QAC3DC,OAAO;YACLC,YAAY;gBACVC,OAAO;oBACLC,MAAM7B;oBACN8B,aAAa1B,oBAAoBC,cAAcC;gBACjD;YACF;QACF;IACF;IAEA,OAAOyB,eAAeX,OAAOD;AAC/B;AAEA;;;;;;CAMC,GACD,OAAO,SAASa,mBACd3B,YAA2C,EAC3Cc,SAA0B,EAC1Bb,QAAiB;IAEjB,MAAMc,QAAe;QACnBC,MAAM;QACNC,MAAM;QACNC,OAAO;YAAEC,IAAI;YAAWC,IAAI;QAAU;QACtCC,OAAO;YACLC,YAAY;gBACVC,OAAO;oBACLC,MAAM3B;oBACN4B,aAAa1B,oBAAoBC,cAAcC;gBACjD;YACF;YACA2B,aAAa;gBACXT,IAAI;gBACJC,IAAI;YACN;YACAS,UAAU;QACZ;QACAC,UAAU;IACZ;IAEA,OAAOJ,eAAeX,OAAOD;AAC/B;AAEA;;;;;CAKC,GACD,OAAO,SAASiB,UAAU,EACxB9B,QAAQ,EACR+B,UAAU,EACVhC,YAAY,EACZiC,UAAU,EACI;IACd,MAAMC,iBAAwB;QAC5BlB,MAAM;QACNC,MAAM;QACNI,OAAO;YACLc,UAAU;YACVN,UAAU;QACZ;QACAX,OAAO;YAAEC,IAAI;YAAsBC,IAAI;QAAsB;QAC7DgB,WAAW;IACb;IAEA,MAAMC,gBAAuB;QAC3BrB,MAAM;QACNC,MAAM;QACNI,OAAO;YACLc,UAAU;YACVN,UAAU;QACZ;QACAX,OAAO;YAAEC,IAAI;YAAaC,IAAI;QAAuB;IACvD;IAEA,MAAMkB,cAAqB;QACzBtB,MAAM;QACNC,MAAM;QACNI,OAAO;YACLC,YAAY;gBACVC,OAAO;oBACLC,MAAM5B;oBACN6B,aAAa1B,oBAAoBC,cAAcC;gBACjD;YACF;YACAsC,QAAQ;gBACNC,eAAe;YACjB;YACAL,UAAU;QACZ;IACF;IAEA,4EAA4E;IAC5E,iCAAiC;IACjC,KAAKF;IAEL,OAAO;WAAID,WAAWS,MAAM;QAAEP;QAAgBG;QAAeC;KAAY;AAC3E;AAEA,SAASZ,eAAeX,KAAY,EAAED,SAA0B;IAC9D,IAAI,CAACA,WAAW;QACd,OAAOC;IACT;IAEA,OAAO2B,OAAOC,MAAM,CAAC5B,OAAOD;AAC9B"}
@@ -0,0 +1,2 @@
1
+ export { BITSNAP_LINK_TO_DOC_COMPONENT_PATH, BITSNAP_MANAGER_COMPONENT_PATH, BITSNAP_PRODUCT_SELECT_COMPONENT_PATH, DEFAULT_API_ROUTE, bitsnapClientConfig, bitsnapManagerField, getFields, productSelectField, } from './getFields.js';
2
+ export type { GetFieldsArgs } from './getFields.js';
@@ -0,0 +1,3 @@
1
+ export { BITSNAP_LINK_TO_DOC_COMPONENT_PATH, BITSNAP_MANAGER_COMPONENT_PATH, BITSNAP_PRODUCT_SELECT_COMPONENT_PATH, DEFAULT_API_ROUTE, bitsnapClientConfig, bitsnapManagerField, getFields, productSelectField } from './getFields.js';
2
+
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/fields/index.ts"],"sourcesContent":["export {\n BITSNAP_LINK_TO_DOC_COMPONENT_PATH,\n BITSNAP_MANAGER_COMPONENT_PATH,\n BITSNAP_PRODUCT_SELECT_COMPONENT_PATH,\n DEFAULT_API_ROUTE,\n bitsnapClientConfig,\n bitsnapManagerField,\n getFields,\n productSelectField,\n} from './getFields.js'\nexport type { GetFieldsArgs } from './getFields.js'\n"],"names":["BITSNAP_LINK_TO_DOC_COMPONENT_PATH","BITSNAP_MANAGER_COMPONENT_PATH","BITSNAP_PRODUCT_SELECT_COMPONENT_PATH","DEFAULT_API_ROUTE","bitsnapClientConfig","bitsnapManagerField","getFields","productSelectField"],"mappings":"AAAA,SACEA,kCAAkC,EAClCC,8BAA8B,EAC9BC,qCAAqC,EACrCC,iBAAiB,EACjBC,mBAAmB,EACnBC,mBAAmB,EACnBC,SAAS,EACTC,kBAAkB,QACb,iBAAgB"}
@@ -0,0 +1,7 @@
1
+ export { BITSNAP_LINK_TO_DOC_COMPONENT_PATH, BITSNAP_MANAGER_COMPONENT_PATH, BITSNAP_PRODUCT_SELECT_COMPONENT_PATH, DEFAULT_API_ROUTE, bitsnapClientConfig, bitsnapManagerField, getFields, productSelectField, } from './fields/index.js';
2
+ export type { GetFieldsArgs } from './fields/index.js';
3
+ export { bitsnapPlugin, sanitizeBitsnapPluginConfig } from './plugin.js';
4
+ export { bitsnapCreateSchema, bitsnapErrorMessage, bitsnapErrorResponse, bitsnapStatusSchema, bitsnapUpdateSchema, bitsnapVariantSchema, configureBitsnapBackend, createBitsnapEndpoints, createManagedProduct, getBitsnapCurrency, getManagedProduct, getShopProducts, isBitsnapApiKeyConfigured, resolveBitsnapApiKey, setBitsnapCurrency, updateManagedProduct, } from './server/index.js';
5
+ export type { BitsnapCreateInput, BitsnapStatus, BitsnapUpdateInput, BitsnapVariantInput, ConfigureBitsnapBackendArgs, ShopProductsResult, } from './server/index.js';
6
+ export { DEFAULT_API_BASE_PATH, DEFAULT_CURRENCY, DEFAULT_DASHBOARD_URL, DEFAULT_PRODUCTS_LIMIT, } from './constants.js';
7
+ export type { BitsnapClientConfig, BitsnapPluginConfig, BitsnapProxy, BitsnapWebhookHandler, BitsnapWebhookHandlers, FieldSyncConfig, SanitizedBitsnapPluginConfig, SyncConfig, } from './types.js';
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export { BITSNAP_LINK_TO_DOC_COMPONENT_PATH, BITSNAP_MANAGER_COMPONENT_PATH, BITSNAP_PRODUCT_SELECT_COMPONENT_PATH, DEFAULT_API_ROUTE, bitsnapClientConfig, bitsnapManagerField, getFields, productSelectField } from './fields/index.js';
2
+ export { bitsnapPlugin, sanitizeBitsnapPluginConfig } from './plugin.js';
3
+ export { bitsnapCreateSchema, bitsnapErrorMessage, bitsnapErrorResponse, bitsnapStatusSchema, bitsnapUpdateSchema, bitsnapVariantSchema, configureBitsnapBackend, createBitsnapEndpoints, createManagedProduct, getBitsnapCurrency, getManagedProduct, getShopProducts, isBitsnapApiKeyConfigured, resolveBitsnapApiKey, setBitsnapCurrency, updateManagedProduct } from './server/index.js';
4
+ export { DEFAULT_API_BASE_PATH, DEFAULT_CURRENCY, DEFAULT_DASHBOARD_URL, DEFAULT_PRODUCTS_LIMIT } from './constants.js';
5
+
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {\n BITSNAP_LINK_TO_DOC_COMPONENT_PATH,\n BITSNAP_MANAGER_COMPONENT_PATH,\n BITSNAP_PRODUCT_SELECT_COMPONENT_PATH,\n DEFAULT_API_ROUTE,\n bitsnapClientConfig,\n bitsnapManagerField,\n getFields,\n productSelectField,\n} from './fields/index.js'\nexport type { GetFieldsArgs } from './fields/index.js'\nexport { bitsnapPlugin, sanitizeBitsnapPluginConfig } from './plugin.js'\nexport {\n bitsnapCreateSchema,\n bitsnapErrorMessage,\n bitsnapErrorResponse,\n bitsnapStatusSchema,\n bitsnapUpdateSchema,\n bitsnapVariantSchema,\n configureBitsnapBackend,\n createBitsnapEndpoints,\n createManagedProduct,\n getBitsnapCurrency,\n getManagedProduct,\n getShopProducts,\n isBitsnapApiKeyConfigured,\n resolveBitsnapApiKey,\n setBitsnapCurrency,\n updateManagedProduct,\n} from './server/index.js'\nexport type {\n BitsnapCreateInput,\n BitsnapStatus,\n BitsnapUpdateInput,\n BitsnapVariantInput,\n ConfigureBitsnapBackendArgs,\n ShopProductsResult,\n} from './server/index.js'\nexport {\n DEFAULT_API_BASE_PATH,\n DEFAULT_CURRENCY,\n DEFAULT_DASHBOARD_URL,\n DEFAULT_PRODUCTS_LIMIT,\n} from './constants.js'\nexport type {\n BitsnapClientConfig,\n BitsnapPluginConfig,\n BitsnapProxy,\n BitsnapWebhookHandler,\n BitsnapWebhookHandlers,\n FieldSyncConfig,\n SanitizedBitsnapPluginConfig,\n SyncConfig,\n} from './types.js'\n"],"names":["BITSNAP_LINK_TO_DOC_COMPONENT_PATH","BITSNAP_MANAGER_COMPONENT_PATH","BITSNAP_PRODUCT_SELECT_COMPONENT_PATH","DEFAULT_API_ROUTE","bitsnapClientConfig","bitsnapManagerField","getFields","productSelectField","bitsnapPlugin","sanitizeBitsnapPluginConfig","bitsnapCreateSchema","bitsnapErrorMessage","bitsnapErrorResponse","bitsnapStatusSchema","bitsnapUpdateSchema","bitsnapVariantSchema","configureBitsnapBackend","createBitsnapEndpoints","createManagedProduct","getBitsnapCurrency","getManagedProduct","getShopProducts","isBitsnapApiKeyConfigured","resolveBitsnapApiKey","setBitsnapCurrency","updateManagedProduct","DEFAULT_API_BASE_PATH","DEFAULT_CURRENCY","DEFAULT_DASHBOARD_URL","DEFAULT_PRODUCTS_LIMIT"],"mappings":"AAAA,SACEA,kCAAkC,EAClCC,8BAA8B,EAC9BC,qCAAqC,EACrCC,iBAAiB,EACjBC,mBAAmB,EACnBC,mBAAmB,EACnBC,SAAS,EACTC,kBAAkB,QACb,oBAAmB;AAE1B,SAASC,aAAa,EAAEC,2BAA2B,QAAQ,cAAa;AACxE,SACEC,mBAAmB,EACnBC,mBAAmB,EACnBC,oBAAoB,EACpBC,mBAAmB,EACnBC,mBAAmB,EACnBC,oBAAoB,EACpBC,uBAAuB,EACvBC,sBAAsB,EACtBC,oBAAoB,EACpBC,kBAAkB,EAClBC,iBAAiB,EACjBC,eAAe,EACfC,yBAAyB,EACzBC,oBAAoB,EACpBC,kBAAkB,EAClBC,oBAAoB,QACf,oBAAmB;AAS1B,SACEC,qBAAqB,EACrBC,gBAAgB,EAChBC,qBAAqB,EACrBC,sBAAsB,QACjB,iBAAgB"}
@@ -0,0 +1,15 @@
1
+ import type { Plugin } from 'payload';
2
+ import type { BitsnapPluginConfig, SanitizedBitsnapPluginConfig } from './types.js';
3
+ /**
4
+ * Fills in every default the plugin needs so the rest of the code can rely on
5
+ * a fully populated configuration.
6
+ */
7
+ export declare function sanitizeBitsnapPluginConfig(pluginConfig: BitsnapPluginConfig): SanitizedBitsnapPluginConfig;
8
+ /**
9
+ * Payload plugin that wires Bitsnap into a Payload project.
10
+ *
11
+ * - appends the Bitsnap fields to every collection listed in `sync`
12
+ * - mounts the Bitsnap REST endpoints on the Payload API root
13
+ * - points the Bitsnap SDK at the configured host and API key
14
+ */
15
+ export declare const bitsnapPlugin: (pluginConfig: BitsnapPluginConfig) => Plugin;