bitsnap-payloadcms 0.0.0-stage → 0.1.2

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
@@ -0,0 +1,75 @@
1
+ import type { Config as PayloadConfig, Payload, PayloadRequest } from 'payload';
2
+ export type BitsnapWebhookHandler<T = any> = (args: {
3
+ config: PayloadConfig;
4
+ event: T;
5
+ payload: Payload;
6
+ pluginConfig?: BitsnapPluginConfig;
7
+ req: PayloadRequest;
8
+ }) => Promise<void> | void;
9
+ export type BitsnapWebhookHandlers = {
10
+ [webhookName: string]: BitsnapWebhookHandler;
11
+ };
12
+ export type FieldSyncConfig = {
13
+ fieldPath: string;
14
+ bitsnapProperty: string;
15
+ };
16
+ export type SyncConfig = {
17
+ collection: string;
18
+ fields: FieldSyncConfig[];
19
+ };
20
+ export type BitsnapPluginConfig = {
21
+ /**
22
+ * Bitsnap API key. Server-side only — never sent to the browser.
23
+ */
24
+ bitsnapApiKey: string;
25
+ /**
26
+ * Bitsnap project ID. Falls back to `process.env.BITSNAP_PROJECT_ID`.
27
+ */
28
+ projectId?: string;
29
+ /**
30
+ * Base URL of the Bitsnap dashboard. Default: `https://bitsnap.pl`.
31
+ */
32
+ dashboardUrl?: string;
33
+ /**
34
+ * Path the plugin mounts its REST endpoints on, relative to the Payload API root.
35
+ * Default: `/bitsnap`.
36
+ */
37
+ apiBasePath?: string;
38
+ /**
39
+ * Currency used when creating products and variants. Default: `PLN`.
40
+ */
41
+ currency?: string;
42
+ logs?: boolean;
43
+ sync?: SyncConfig[];
44
+ webhooks?: BitsnapWebhookHandler | BitsnapWebhookHandlers;
45
+ };
46
+ export type SanitizedBitsnapPluginConfig = {
47
+ apiBasePath: string;
48
+ currency: string;
49
+ dashboardUrl: string;
50
+ projectId: string;
51
+ sync: SyncConfig[];
52
+ } & BitsnapPluginConfig;
53
+ /**
54
+ * Values the admin UI components need. Passed to them through Payload's
55
+ * `clientProps` mechanism — see `admin.components.Field.clientProps`.
56
+ */
57
+ export type BitsnapClientConfig = {
58
+ /**
59
+ * Path prefix of the plugin's REST endpoints, including the Payload API root.
60
+ * Example: `/api/bitsnap`.
61
+ */
62
+ apiBaseUrl: string;
63
+ currency: string;
64
+ dashboardUrl: string;
65
+ projectId: string;
66
+ };
67
+ export type BitsnapProxy = (args: {
68
+ bitsnapArgs: any[];
69
+ bitsnapMethod: string;
70
+ bitsnapApiKey: string;
71
+ }) => Promise<{
72
+ data?: any;
73
+ message?: string;
74
+ status: number;
75
+ }>;
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { Config as PayloadConfig, Payload, PayloadRequest } from 'payload'\n\nexport type BitsnapWebhookHandler<T = any> = (args: {\n config: PayloadConfig\n event: T\n payload: Payload\n pluginConfig?: BitsnapPluginConfig\n req: PayloadRequest\n}) => Promise<void> | void\n\nexport type BitsnapWebhookHandlers = {\n [webhookName: string]: BitsnapWebhookHandler\n}\n\nexport type FieldSyncConfig = {\n fieldPath: string\n bitsnapProperty: string\n}\n\nexport type SyncConfig = {\n collection: string\n fields: FieldSyncConfig[]\n}\n\nexport type BitsnapPluginConfig = {\n /**\n * Bitsnap API key. Server-side only — never sent to the browser.\n */\n bitsnapApiKey: string\n /**\n * Bitsnap project ID. Falls back to `process.env.BITSNAP_PROJECT_ID`.\n */\n projectId?: string\n /**\n * Base URL of the Bitsnap dashboard. Default: `https://bitsnap.pl`.\n */\n dashboardUrl?: string\n /**\n * Path the plugin mounts its REST endpoints on, relative to the Payload API root.\n * Default: `/bitsnap`.\n */\n apiBasePath?: string\n /**\n * Currency used when creating products and variants. Default: `PLN`.\n */\n currency?: string\n logs?: boolean\n sync?: SyncConfig[]\n webhooks?: BitsnapWebhookHandler | BitsnapWebhookHandlers\n}\n\nexport type SanitizedBitsnapPluginConfig = {\n apiBasePath: string\n currency: string\n dashboardUrl: string\n projectId: string\n sync: SyncConfig[]\n} & BitsnapPluginConfig\n\n/**\n * Values the admin UI components need. Passed to them through Payload's\n * `clientProps` mechanism — see `admin.components.Field.clientProps`.\n */\nexport type BitsnapClientConfig = {\n /**\n * Path prefix of the plugin's REST endpoints, including the Payload API root.\n * Example: `/api/bitsnap`.\n */\n apiBaseUrl: string\n currency: string\n dashboardUrl: string\n projectId: string\n}\n\nexport type BitsnapProxy = (args: {\n bitsnapArgs: any[]\n bitsnapMethod: string\n bitsnapApiKey: string\n}) => Promise<{\n data?: any\n message?: string\n status: number\n}>\n"],"names":[],"mappings":"AA0EA,WAQE"}
@@ -0,0 +1,159 @@
1
+ .bitsnap-manager {
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: var(--base, 20px);
5
+ }
6
+
7
+ .bitsnap-manager .group-field__header {
8
+ margin-bottom: 0;
9
+ }
10
+
11
+ .bitsnap-manager .field-type.row .row__fields:has(> *:nth-child(1)) {
12
+ margin-bottom: 0;
13
+ }
14
+
15
+ .bitsnap-manager .field-type {
16
+ margin-bottom: 0;
17
+ }
18
+
19
+ .bitsnap-manager__col--half {
20
+ --field-width: 50%;
21
+ }
22
+
23
+ .bitsnap-manager__col--third {
24
+ --field-width: 33.33%;
25
+ }
26
+
27
+ .bitsnap-manager__col--quarter {
28
+ --field-width: 25%;
29
+ }
30
+
31
+ .bitsnap-manager__lead,
32
+ .bitsnap-manager__empty {
33
+ margin: 0;
34
+ max-width: 68ch;
35
+ color: var(--theme-elevation-500, #9a9a9a);
36
+ }
37
+
38
+ .bitsnap-manager__loading {
39
+ display: grid;
40
+ gap: calc(var(--base, 20px) * 0.5);
41
+ }
42
+
43
+ .bitsnap-manager__loading-row {
44
+ height: 40px;
45
+ border-radius: var(--style-radius-s, 4px);
46
+ background-color: var(--theme-elevation-100, #262626);
47
+ animation: bitsnap-manager-pulse 1.4s ease-in-out infinite;
48
+ }
49
+
50
+ @keyframes bitsnap-manager-pulse {
51
+ 0%,
52
+ 100% {
53
+ opacity: 1;
54
+ }
55
+
56
+ 50% {
57
+ opacity: 0.4;
58
+ }
59
+ }
60
+
61
+ .bitsnap-manager__variants {
62
+ display: flex;
63
+ flex-direction: column;
64
+ align-items: flex-start;
65
+ gap: calc(var(--base, 20px) * 0.75);
66
+ padding-top: var(--base, 20px);
67
+ border-top: 1px solid var(--theme-elevation-100, #262626);
68
+ }
69
+
70
+ .bitsnap-manager__variants-header {
71
+ display: flex;
72
+ align-items: center;
73
+ gap: calc(var(--base, 20px) * 0.5);
74
+ }
75
+
76
+ .bitsnap-manager__variants-title {
77
+ margin: 0;
78
+ }
79
+
80
+ .bitsnap-manager__grid {
81
+ display: grid;
82
+ gap: calc(var(--base, 20px) * 0.5);
83
+ width: 100%;
84
+ }
85
+
86
+ .bitsnap-manager__grid-head,
87
+ .bitsnap-manager__grid-row {
88
+ display: grid;
89
+ grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) calc(var(--base, 20px) * 1.6);
90
+ align-items: center;
91
+ gap: calc(var(--base, 20px) * 0.5);
92
+ }
93
+
94
+ .bitsnap-manager__grid-head .field-label {
95
+ margin: 0;
96
+ }
97
+
98
+ .bitsnap-manager__grid-row input {
99
+ font-variant-numeric: tabular-nums;
100
+ }
101
+
102
+ .bitsnap-manager__remove {
103
+ display: flex;
104
+ justify-content: center;
105
+ }
106
+
107
+ .bitsnap-manager__sr-only {
108
+ position: absolute;
109
+ width: 1px;
110
+ height: 1px;
111
+ overflow: hidden;
112
+ clip: rect(0 0 0 0);
113
+ white-space: nowrap;
114
+ }
115
+
116
+ .bitsnap-manager__actions {
117
+ display: flex;
118
+ flex-wrap: wrap;
119
+ gap: calc(var(--base, 20px) * 0.5);
120
+ padding-top: var(--base, 20px);
121
+ border-top: 1px solid var(--theme-elevation-100, #262626);
122
+ }
123
+
124
+ .bitsnap-manager__actions .btn {
125
+ margin: 0;
126
+ }
127
+
128
+ .bitsnap-manager__meta {
129
+ display: flex;
130
+ align-items: center;
131
+ gap: calc(var(--base, 20px) * 0.4);
132
+ color: var(--theme-elevation-500, #9a9a9a);
133
+ font-size: calc(var(--base-body-size, 13) * 0.92px);
134
+ }
135
+
136
+ .bitsnap-manager__meta code {
137
+ color: var(--theme-elevation-800, #fafafa);
138
+ font-variant-numeric: tabular-nums;
139
+ }
140
+
141
+ @media (max-width: 768px) {
142
+ .bitsnap-manager__grid-head {
143
+ display: none;
144
+ }
145
+
146
+ .bitsnap-manager__grid-row {
147
+ grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) calc(var(--base, 20px) * 1.6);
148
+ padding-bottom: calc(var(--base, 20px) * 0.5);
149
+ border-bottom: 1px solid var(--theme-elevation-100, #262626);
150
+ }
151
+
152
+ .bitsnap-manager__grid-row > [role='cell']:first-child {
153
+ grid-column: 1 / -1;
154
+ }
155
+ }
156
+
157
+ .bitsnap-manager__actions .bitsnap-manager__open {
158
+ margin-left: auto;
159
+ }
@@ -0,0 +1,5 @@
1
+ import type { UIFieldClientProps } from 'payload';
2
+ import type { BitsnapClientConfig } from '../types.js';
3
+ import './BitsnapManager.css';
4
+ export type BitsnapManagerProps = UIFieldClientProps & Partial<BitsnapClientConfig>;
5
+ export declare const BitsnapManager: (props: BitsnapManagerProps) => import("react").JSX.Element;