@truecodeio/sdk-core 0.2.10 → 0.2.12

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.
@@ -43,6 +43,13 @@ declare const appRouter: import('@trpc/server').TRPCBuiltRouter<{
43
43
  };
44
44
  meta: object;
45
45
  }>;
46
+ getOrganizationApiKey: import('@trpc/server').TRPCQueryProcedure<{
47
+ input: void;
48
+ output: {
49
+ key: string;
50
+ };
51
+ meta: object;
52
+ }>;
46
53
  getCampaigns: import('@trpc/server').TRPCQueryProcedure<{
47
54
  input: void;
48
55
  output: {
@@ -54,6 +61,19 @@ declare const appRouter: import('@trpc/server').TRPCBuiltRouter<{
54
61
  createdAt: Date;
55
62
  updatedAt: Date;
56
63
  status: string;
64
+ scheduledStartAt: Date | null;
65
+ scheduledEndAt: Date | null;
66
+ targeting: {
67
+ rules: {
68
+ id: string;
69
+ value: string;
70
+ operator: string;
71
+ }[];
72
+ locations: {
73
+ type: "include" | "exclude";
74
+ path: string;
75
+ }[];
76
+ };
57
77
  }[];
58
78
  meta: object;
59
79
  }>;
@@ -70,6 +90,19 @@ declare const appRouter: import('@trpc/server').TRPCBuiltRouter<{
70
90
  createdAt: Date;
71
91
  updatedAt: Date;
72
92
  status: string;
93
+ scheduledStartAt: Date | null;
94
+ scheduledEndAt: Date | null;
95
+ targeting: {
96
+ rules: {
97
+ id: string;
98
+ value: string;
99
+ operator: string;
100
+ }[];
101
+ locations: {
102
+ type: "include" | "exclude";
103
+ path: string;
104
+ }[];
105
+ };
73
106
  };
74
107
  meta: object;
75
108
  }>;
@@ -79,6 +112,19 @@ declare const appRouter: import('@trpc/server').TRPCBuiltRouter<{
79
112
  templateId: string;
80
113
  createdAt?: Date | undefined;
81
114
  updatedAt?: Date | undefined;
115
+ scheduledStartAt?: Date | null | undefined;
116
+ scheduledEndAt?: Date | null | undefined;
117
+ targeting?: {
118
+ rules: {
119
+ id: string;
120
+ value: string;
121
+ operator: string;
122
+ }[];
123
+ locations: {
124
+ type: "include" | "exclude";
125
+ path: string;
126
+ }[];
127
+ } | undefined;
82
128
  };
83
129
  output: void;
84
130
  meta: object;
@@ -89,6 +135,19 @@ declare const appRouter: import('@trpc/server').TRPCBuiltRouter<{
89
135
  name?: string | undefined;
90
136
  status?: string | undefined;
91
137
  templateId?: string | undefined;
138
+ scheduledStartAt?: Date | null | undefined;
139
+ scheduledEndAt?: Date | null | undefined;
140
+ targeting?: {
141
+ rules: {
142
+ id: string;
143
+ value: string;
144
+ operator: string;
145
+ }[];
146
+ locations: {
147
+ type: "include" | "exclude";
148
+ path: string;
149
+ }[];
150
+ } | undefined;
92
151
  };
93
152
  output: {
94
153
  id: string;
@@ -99,6 +158,19 @@ declare const appRouter: import('@trpc/server').TRPCBuiltRouter<{
99
158
  createdAt: Date;
100
159
  updatedAt: Date;
101
160
  status: string;
161
+ scheduledStartAt: Date | null;
162
+ scheduledEndAt: Date | null;
163
+ targeting: {
164
+ rules: {
165
+ id: string;
166
+ value: string;
167
+ operator: string;
168
+ }[];
169
+ locations: {
170
+ type: "include" | "exclude";
171
+ path: string;
172
+ }[];
173
+ };
102
174
  };
103
175
  meta: object;
104
176
  }>;
@@ -154,7 +226,7 @@ declare const appRouter: import('@trpc/server').TRPCBuiltRouter<{
154
226
  templateUpdate: import('@trpc/server').TRPCMutationProcedure<{
155
227
  input: {
156
228
  id: string;
157
- name?: string | undefined;
229
+ name: string;
158
230
  content?: unknown;
159
231
  status?: string | undefined;
160
232
  };
@@ -186,6 +258,213 @@ declare const appRouter: import('@trpc/server').TRPCBuiltRouter<{
186
258
  };
187
259
  meta: object;
188
260
  }>;
261
+ getCustomComponents: import('@trpc/server').TRPCQueryProcedure<{
262
+ input: void;
263
+ output: {
264
+ id: string;
265
+ organizationId: string;
266
+ name: string;
267
+ componentId: string;
268
+ createdAt: Date;
269
+ updatedAt: Date;
270
+ }[];
271
+ meta: object;
272
+ }>;
273
+ createCustomComponent: import('@trpc/server').TRPCMutationProcedure<{
274
+ input: {
275
+ name: string;
276
+ componentId: string;
277
+ };
278
+ output: {
279
+ id: string;
280
+ name: string;
281
+ createdAt: Date;
282
+ updatedAt: Date;
283
+ organizationId: string;
284
+ componentId: string;
285
+ };
286
+ meta: object;
287
+ }>;
288
+ updateCustomComponent: import('@trpc/server').TRPCMutationProcedure<{
289
+ input: {
290
+ id: string;
291
+ name: string;
292
+ componentId: string;
293
+ };
294
+ output: {
295
+ id: string;
296
+ organizationId: string;
297
+ name: string;
298
+ componentId: string;
299
+ createdAt: Date;
300
+ updatedAt: Date;
301
+ };
302
+ meta: object;
303
+ }>;
304
+ deleteCustomComponent: import('@trpc/server').TRPCMutationProcedure<{
305
+ input: {
306
+ id: string;
307
+ };
308
+ output: {
309
+ id: string;
310
+ name: string;
311
+ createdAt: Date;
312
+ updatedAt: Date;
313
+ organizationId: string;
314
+ componentId: string;
315
+ };
316
+ meta: object;
317
+ }>;
318
+ getProperties: import('@trpc/server').TRPCQueryProcedure<{
319
+ input: void;
320
+ output: ({
321
+ id: string;
322
+ propertyId: string;
323
+ name: string;
324
+ type: "string";
325
+ options: never[];
326
+ } | {
327
+ id: string;
328
+ propertyId: string;
329
+ name: string;
330
+ type: "number";
331
+ options: never[];
332
+ } | {
333
+ id: string;
334
+ propertyId: string;
335
+ name: string;
336
+ type: "boolean";
337
+ options: never[];
338
+ } | {
339
+ id: string;
340
+ propertyId: string;
341
+ name: string;
342
+ type: "options";
343
+ options: {
344
+ id: string;
345
+ label: string;
346
+ }[];
347
+ })[];
348
+ meta: object;
349
+ }>;
350
+ getProperty: import('@trpc/server').TRPCQueryProcedure<{
351
+ input: {
352
+ id: string;
353
+ };
354
+ output: {
355
+ id: string;
356
+ propertyId: string;
357
+ name: string;
358
+ type: "string";
359
+ options: never[];
360
+ } | {
361
+ id: string;
362
+ propertyId: string;
363
+ name: string;
364
+ type: "number";
365
+ options: never[];
366
+ } | {
367
+ id: string;
368
+ propertyId: string;
369
+ name: string;
370
+ type: "boolean";
371
+ options: never[];
372
+ } | {
373
+ id: string;
374
+ propertyId: string;
375
+ name: string;
376
+ type: "options";
377
+ options: {
378
+ id: string;
379
+ label: string;
380
+ }[];
381
+ };
382
+ meta: object;
383
+ }>;
384
+ createProperty: import('@trpc/server').TRPCMutationProcedure<{
385
+ input: {
386
+ name: string;
387
+ type: string;
388
+ propertyId: string;
389
+ options?: {
390
+ id: string;
391
+ label: string;
392
+ }[] | undefined;
393
+ };
394
+ output: {
395
+ id: string;
396
+ propertyId: string;
397
+ name: string;
398
+ type: "string";
399
+ options: never[];
400
+ } | {
401
+ id: string;
402
+ propertyId: string;
403
+ name: string;
404
+ type: "number";
405
+ options: never[];
406
+ } | {
407
+ id: string;
408
+ propertyId: string;
409
+ name: string;
410
+ type: "boolean";
411
+ options: never[];
412
+ } | {
413
+ id: string;
414
+ propertyId: string;
415
+ name: string;
416
+ type: "options";
417
+ options: {
418
+ id: string;
419
+ label: string;
420
+ }[];
421
+ };
422
+ meta: object;
423
+ }>;
424
+ updateProperty: import('@trpc/server').TRPCMutationProcedure<{
425
+ input: {
426
+ id: string;
427
+ name: string;
428
+ };
429
+ output: {
430
+ id: string;
431
+ propertyId: string;
432
+ name: string;
433
+ type: "string";
434
+ options: never[];
435
+ } | {
436
+ id: string;
437
+ propertyId: string;
438
+ name: string;
439
+ type: "number";
440
+ options: never[];
441
+ } | {
442
+ id: string;
443
+ propertyId: string;
444
+ name: string;
445
+ type: "boolean";
446
+ options: never[];
447
+ } | {
448
+ id: string;
449
+ propertyId: string;
450
+ name: string;
451
+ type: "options";
452
+ options: {
453
+ id: string;
454
+ label: string;
455
+ }[];
456
+ };
457
+ meta: object;
458
+ }>;
459
+ deleteProperty: import('@trpc/server').TRPCMutationProcedure<{
460
+ input: {
461
+ id: string;
462
+ };
463
+ output: {
464
+ success: boolean;
465
+ };
466
+ meta: object;
467
+ }>;
189
468
  inviteUser: import('@trpc/server').TRPCMutationProcedure<{
190
469
  input: {
191
470
  email: string;
@@ -209,7 +488,10 @@ declare const appRouter: import('@trpc/server').TRPCBuiltRouter<{
209
488
  meta: object;
210
489
  }>;
211
490
  getEligibleCampaign: import('@trpc/server').TRPCQueryProcedure<{
212
- input: void;
491
+ input: {
492
+ pathname: string;
493
+ properties?: Record<string, string | number | boolean> | undefined;
494
+ };
213
495
  output: {
214
496
  id: string;
215
497
  template: {
@@ -222,7 +504,7 @@ declare const appRouter: import('@trpc/server').TRPCBuiltRouter<{
222
504
  updatedAt: Date;
223
505
  status: string;
224
506
  };
225
- } | null;
507
+ };
226
508
  meta: object;
227
509
  }>;
228
510
  generateImageUploadUrl: import('@trpc/server').TRPCMutationProcedure<{
package/dist/client.d.ts CHANGED
@@ -46,6 +46,13 @@ export declare const createClient: ({ apiKey }: ClientConfig) => import('@trpc/c
46
46
  };
47
47
  meta: object;
48
48
  }>;
49
+ getOrganizationApiKey: import('@trpc/server').TRPCQueryProcedure<{
50
+ input: void;
51
+ output: {
52
+ key: string;
53
+ };
54
+ meta: object;
55
+ }>;
49
56
  getCampaigns: import('@trpc/server').TRPCQueryProcedure<{
50
57
  input: void;
51
58
  output: {
@@ -57,6 +64,19 @@ export declare const createClient: ({ apiKey }: ClientConfig) => import('@trpc/c
57
64
  createdAt: Date;
58
65
  updatedAt: Date;
59
66
  status: string;
67
+ scheduledStartAt: Date | null;
68
+ scheduledEndAt: Date | null;
69
+ targeting: {
70
+ rules: {
71
+ id: string;
72
+ value: string;
73
+ operator: string;
74
+ }[];
75
+ locations: {
76
+ type: "include" | "exclude";
77
+ path: string;
78
+ }[];
79
+ };
60
80
  }[];
61
81
  meta: object;
62
82
  }>;
@@ -73,6 +93,19 @@ export declare const createClient: ({ apiKey }: ClientConfig) => import('@trpc/c
73
93
  createdAt: Date;
74
94
  updatedAt: Date;
75
95
  status: string;
96
+ scheduledStartAt: Date | null;
97
+ scheduledEndAt: Date | null;
98
+ targeting: {
99
+ rules: {
100
+ id: string;
101
+ value: string;
102
+ operator: string;
103
+ }[];
104
+ locations: {
105
+ type: "include" | "exclude";
106
+ path: string;
107
+ }[];
108
+ };
76
109
  };
77
110
  meta: object;
78
111
  }>;
@@ -82,6 +115,19 @@ export declare const createClient: ({ apiKey }: ClientConfig) => import('@trpc/c
82
115
  templateId: string;
83
116
  createdAt?: Date | undefined;
84
117
  updatedAt?: Date | undefined;
118
+ scheduledStartAt?: Date | null | undefined;
119
+ scheduledEndAt?: Date | null | undefined;
120
+ targeting?: {
121
+ rules: {
122
+ id: string;
123
+ value: string;
124
+ operator: string;
125
+ }[];
126
+ locations: {
127
+ type: "include" | "exclude";
128
+ path: string;
129
+ }[];
130
+ } | undefined;
85
131
  };
86
132
  output: void;
87
133
  meta: object;
@@ -92,6 +138,19 @@ export declare const createClient: ({ apiKey }: ClientConfig) => import('@trpc/c
92
138
  name?: string | undefined;
93
139
  status?: string | undefined;
94
140
  templateId?: string | undefined;
141
+ scheduledStartAt?: Date | null | undefined;
142
+ scheduledEndAt?: Date | null | undefined;
143
+ targeting?: {
144
+ rules: {
145
+ id: string;
146
+ value: string;
147
+ operator: string;
148
+ }[];
149
+ locations: {
150
+ type: "include" | "exclude";
151
+ path: string;
152
+ }[];
153
+ } | undefined;
95
154
  };
96
155
  output: {
97
156
  id: string;
@@ -102,6 +161,19 @@ export declare const createClient: ({ apiKey }: ClientConfig) => import('@trpc/c
102
161
  createdAt: Date;
103
162
  updatedAt: Date;
104
163
  status: string;
164
+ scheduledStartAt: Date | null;
165
+ scheduledEndAt: Date | null;
166
+ targeting: {
167
+ rules: {
168
+ id: string;
169
+ value: string;
170
+ operator: string;
171
+ }[];
172
+ locations: {
173
+ type: "include" | "exclude";
174
+ path: string;
175
+ }[];
176
+ };
105
177
  };
106
178
  meta: object;
107
179
  }>;
@@ -157,7 +229,7 @@ export declare const createClient: ({ apiKey }: ClientConfig) => import('@trpc/c
157
229
  templateUpdate: import('@trpc/server').TRPCMutationProcedure<{
158
230
  input: {
159
231
  id: string;
160
- name?: string | undefined;
232
+ name: string;
161
233
  content?: unknown;
162
234
  status?: string | undefined;
163
235
  };
@@ -189,6 +261,213 @@ export declare const createClient: ({ apiKey }: ClientConfig) => import('@trpc/c
189
261
  };
190
262
  meta: object;
191
263
  }>;
264
+ getCustomComponents: import('@trpc/server').TRPCQueryProcedure<{
265
+ input: void;
266
+ output: {
267
+ id: string;
268
+ organizationId: string;
269
+ name: string;
270
+ componentId: string;
271
+ createdAt: Date;
272
+ updatedAt: Date;
273
+ }[];
274
+ meta: object;
275
+ }>;
276
+ createCustomComponent: import('@trpc/server').TRPCMutationProcedure<{
277
+ input: {
278
+ name: string;
279
+ componentId: string;
280
+ };
281
+ output: {
282
+ id: string;
283
+ name: string;
284
+ createdAt: Date;
285
+ updatedAt: Date;
286
+ organizationId: string;
287
+ componentId: string;
288
+ };
289
+ meta: object;
290
+ }>;
291
+ updateCustomComponent: import('@trpc/server').TRPCMutationProcedure<{
292
+ input: {
293
+ id: string;
294
+ name: string;
295
+ componentId: string;
296
+ };
297
+ output: {
298
+ id: string;
299
+ organizationId: string;
300
+ name: string;
301
+ componentId: string;
302
+ createdAt: Date;
303
+ updatedAt: Date;
304
+ };
305
+ meta: object;
306
+ }>;
307
+ deleteCustomComponent: import('@trpc/server').TRPCMutationProcedure<{
308
+ input: {
309
+ id: string;
310
+ };
311
+ output: {
312
+ id: string;
313
+ name: string;
314
+ createdAt: Date;
315
+ updatedAt: Date;
316
+ organizationId: string;
317
+ componentId: string;
318
+ };
319
+ meta: object;
320
+ }>;
321
+ getProperties: import('@trpc/server').TRPCQueryProcedure<{
322
+ input: void;
323
+ output: ({
324
+ id: string;
325
+ propertyId: string;
326
+ name: string;
327
+ type: "string";
328
+ options: never[];
329
+ } | {
330
+ id: string;
331
+ propertyId: string;
332
+ name: string;
333
+ type: "number";
334
+ options: never[];
335
+ } | {
336
+ id: string;
337
+ propertyId: string;
338
+ name: string;
339
+ type: "boolean";
340
+ options: never[];
341
+ } | {
342
+ id: string;
343
+ propertyId: string;
344
+ name: string;
345
+ type: "options";
346
+ options: {
347
+ id: string;
348
+ label: string;
349
+ }[];
350
+ })[];
351
+ meta: object;
352
+ }>;
353
+ getProperty: import('@trpc/server').TRPCQueryProcedure<{
354
+ input: {
355
+ id: string;
356
+ };
357
+ output: {
358
+ id: string;
359
+ propertyId: string;
360
+ name: string;
361
+ type: "string";
362
+ options: never[];
363
+ } | {
364
+ id: string;
365
+ propertyId: string;
366
+ name: string;
367
+ type: "number";
368
+ options: never[];
369
+ } | {
370
+ id: string;
371
+ propertyId: string;
372
+ name: string;
373
+ type: "boolean";
374
+ options: never[];
375
+ } | {
376
+ id: string;
377
+ propertyId: string;
378
+ name: string;
379
+ type: "options";
380
+ options: {
381
+ id: string;
382
+ label: string;
383
+ }[];
384
+ };
385
+ meta: object;
386
+ }>;
387
+ createProperty: import('@trpc/server').TRPCMutationProcedure<{
388
+ input: {
389
+ name: string;
390
+ type: string;
391
+ propertyId: string;
392
+ options?: {
393
+ id: string;
394
+ label: string;
395
+ }[] | undefined;
396
+ };
397
+ output: {
398
+ id: string;
399
+ propertyId: string;
400
+ name: string;
401
+ type: "string";
402
+ options: never[];
403
+ } | {
404
+ id: string;
405
+ propertyId: string;
406
+ name: string;
407
+ type: "number";
408
+ options: never[];
409
+ } | {
410
+ id: string;
411
+ propertyId: string;
412
+ name: string;
413
+ type: "boolean";
414
+ options: never[];
415
+ } | {
416
+ id: string;
417
+ propertyId: string;
418
+ name: string;
419
+ type: "options";
420
+ options: {
421
+ id: string;
422
+ label: string;
423
+ }[];
424
+ };
425
+ meta: object;
426
+ }>;
427
+ updateProperty: import('@trpc/server').TRPCMutationProcedure<{
428
+ input: {
429
+ id: string;
430
+ name: string;
431
+ };
432
+ output: {
433
+ id: string;
434
+ propertyId: string;
435
+ name: string;
436
+ type: "string";
437
+ options: never[];
438
+ } | {
439
+ id: string;
440
+ propertyId: string;
441
+ name: string;
442
+ type: "number";
443
+ options: never[];
444
+ } | {
445
+ id: string;
446
+ propertyId: string;
447
+ name: string;
448
+ type: "boolean";
449
+ options: never[];
450
+ } | {
451
+ id: string;
452
+ propertyId: string;
453
+ name: string;
454
+ type: "options";
455
+ options: {
456
+ id: string;
457
+ label: string;
458
+ }[];
459
+ };
460
+ meta: object;
461
+ }>;
462
+ deleteProperty: import('@trpc/server').TRPCMutationProcedure<{
463
+ input: {
464
+ id: string;
465
+ };
466
+ output: {
467
+ success: boolean;
468
+ };
469
+ meta: object;
470
+ }>;
192
471
  inviteUser: import('@trpc/server').TRPCMutationProcedure<{
193
472
  input: {
194
473
  email: string;
@@ -212,7 +491,10 @@ export declare const createClient: ({ apiKey }: ClientConfig) => import('@trpc/c
212
491
  meta: object;
213
492
  }>;
214
493
  getEligibleCampaign: import('@trpc/server').TRPCQueryProcedure<{
215
- input: void;
494
+ input: {
495
+ pathname: string;
496
+ properties?: Record<string, string | number | boolean> | undefined;
497
+ };
216
498
  output: {
217
499
  id: string;
218
500
  template: {
@@ -225,7 +507,7 @@ export declare const createClient: ({ apiKey }: ClientConfig) => import('@trpc/c
225
507
  updatedAt: Date;
226
508
  status: string;
227
509
  };
228
- } | null;
510
+ };
229
511
  meta: object;
230
512
  }>;
231
513
  generateImageUploadUrl: import('@trpc/server').TRPCMutationProcedure<{
package/dist/index.d.ts CHANGED
@@ -1,8 +1,22 @@
1
+ import { SetStateAction } from '@truecodeio/common/common/store/create-store.ts';
1
2
  type ClientOptions = {
2
3
  apiKey: string;
3
4
  };
5
+ type Properties = Record<string, boolean | string | number>;
6
+ type PropertiesStoreValue = Properties;
7
+ type Pathname = string;
8
+ type PathnameStoreValue = Pathname;
4
9
  export declare const createBokoClient: (options: ClientOptions) => {
5
- getEligibleCampaign: () => Promise<{
10
+ propertiesStore: import('@truecodeio/common/common/store/create-store.ts').StoreT<Properties>;
11
+ pathnameStore: import('@truecodeio/common/common/store/create-store.ts').StoreT<string>;
12
+ setProperties: (action: SetStateAction<PropertiesStoreValue>) => void;
13
+ resetProperties: () => void;
14
+ setPathname: (action: SetStateAction<PathnameStoreValue>) => void;
15
+ resetPathname: () => void;
16
+ getEligibleCampaign: ({ properties, pathname, }: {
17
+ properties: Properties;
18
+ pathname: string;
19
+ }) => Promise<{
6
20
  template: {
7
21
  content: Readonly<{
8
22
  id: string;
@@ -75,6 +89,12 @@ export declare const createBokoClient: (options: ClientOptions) => {
75
89
  height: number;
76
90
  preserveAspectRatio: boolean;
77
91
  }>;
92
+ }> | Readonly<{
93
+ id: string;
94
+ type: "custom-component";
95
+ name: string;
96
+ isCollapsed: boolean;
97
+ componentId: string;
78
98
  }> | Readonly<{
79
99
  id: string;
80
100
  type: "button";
@@ -117,7 +137,7 @@ export declare const createBokoClient: (options: ClientOptions) => {
117
137
  status: string;
118
138
  };
119
139
  id: string;
120
- } | null>;
140
+ }>;
121
141
  };
122
142
  export type EligibleCampaign = NonNullable<Awaited<ReturnType<ReturnType<typeof createBokoClient>["getEligibleCampaign"]>>>;
123
143
  export {};
package/dist/index.js CHANGED
@@ -1,17 +1,39 @@
1
- import { createTRPCClient as r, httpBatchLink as a } from "@trpc/client";
2
- import l from "superjson";
1
+ import { createTRPCClient as m, httpBatchLink as p } from "@trpc/client";
2
+ import b from "superjson";
3
3
  import { z as e } from "zod";
4
- const i = ({ apiKey: n }) => r({
4
+ const u = () => {
5
+ const n = /* @__PURE__ */ new Set();
6
+ return {
7
+ dispatch: (t) => {
8
+ for (const i of n)
9
+ i(t);
10
+ },
11
+ subscribe: (t) => (n.add(t), () => {
12
+ n.delete(t);
13
+ })
14
+ };
15
+ }, g = (n, o) => typeof o == "function" ? o(n) : o, d = (n) => {
16
+ const { subscribe: o, dispatch: a } = u();
17
+ let t = n;
18
+ return {
19
+ get: () => t,
20
+ set: (r) => {
21
+ const s = g(t, r);
22
+ s !== t && (t = s, a(t));
23
+ },
24
+ subscribe: o
25
+ };
26
+ }, y = ({ apiKey: n }) => m({
5
27
  links: [
6
- a({
7
- transformer: l,
28
+ p({
29
+ transformer: b,
8
30
  url: "https://boko-server-0d640b8d4fbf.herokuapp.com",
9
31
  headers: () => ({
10
32
  Authorization: `ApiKey ${n}`
11
33
  })
12
34
  })
13
35
  ]
14
- }), c = e.object({
36
+ }), h = e.object({
15
37
  id: e.string(),
16
38
  type: e.literal("spacer"),
17
39
  name: e.string(),
@@ -19,7 +41,7 @@ const i = ({ apiKey: n }) => r({
19
41
  props: e.object({
20
42
  size: e.number()
21
43
  }).readonly()
22
- }).readonly(), s = e.object({
44
+ }).readonly(), f = e.object({
23
45
  id: e.string(),
24
46
  type: e.literal("text"),
25
47
  name: e.string(),
@@ -27,7 +49,7 @@ const i = ({ apiKey: n }) => r({
27
49
  props: e.object({
28
50
  content: e.string()
29
51
  }).readonly()
30
- }).readonly(), d = e.object({
52
+ }).readonly(), j = e.object({
31
53
  id: e.string(),
32
54
  type: e.literal("image"),
33
55
  name: e.string(),
@@ -46,7 +68,13 @@ const i = ({ apiKey: n }) => r({
46
68
  preserveAspectRatio: e.boolean()
47
69
  })
48
70
  ]).readonly()
49
- }).readonly(), m = e.object({
71
+ }).readonly(), S = e.object({
72
+ id: e.string(),
73
+ type: e.literal("custom-component"),
74
+ name: e.string(),
75
+ isCollapsed: e.boolean(),
76
+ componentId: e.string()
77
+ }).readonly(), C = e.object({
50
78
  id: e.string(),
51
79
  type: e.literal("button"),
52
80
  name: e.string(),
@@ -75,31 +103,32 @@ const i = ({ apiKey: n }) => r({
75
103
  fontSize: e.number().min(8).max(72).default(16),
76
104
  fontWeight: e.number().min(100).max(900).multipleOf(100).default(400)
77
105
  }).readonly()
78
- }).readonly(), p = e.enum(["default", "equal", "none"]), b = e.enum(["start", "center", "end"]), g = e.object({
106
+ }).readonly(), z = e.enum(["default", "equal", "none"]), x = e.enum(["start", "center", "end"]), N = e.object({
79
107
  id: e.string(),
80
108
  type: e.literal("column"),
81
109
  name: e.string(),
82
110
  isCollapsed: e.boolean(),
83
111
  props: e.object({
84
- flexChildSize: p,
112
+ flexChildSize: z,
85
113
  alignment: e.object({
86
- vertical: b
114
+ vertical: x
87
115
  }).readonly()
88
116
  }).readonly(),
89
117
  children: e.array(
90
118
  e.lazy(() => e.union([
91
- m,
92
- s,
93
- c,
94
- d
119
+ C,
120
+ f,
121
+ h,
122
+ j,
123
+ S
95
124
  ]))
96
125
  ).readonly()
97
- }).readonly(), u = e.enum([
126
+ }).readonly(), k = e.enum([
98
127
  "default",
99
128
  "start",
100
129
  "center",
101
130
  "end"
102
- ]), y = e.object({
131
+ ]), v = e.object({
103
132
  id: e.string(),
104
133
  type: e.literal("row"),
105
134
  name: e.string(),
@@ -116,13 +145,13 @@ const i = ({ apiKey: n }) => r({
116
145
  color: e.string()
117
146
  }).readonly(),
118
147
  alignment: e.object({
119
- horizontal: u
148
+ horizontal: k
120
149
  }).readonly()
121
150
  }).readonly(),
122
151
  children: e.array(
123
- e.lazy(() => g)
152
+ e.lazy(() => N)
124
153
  ).readonly()
125
- }).readonly(), h = e.object({
154
+ }).readonly(), w = e.object({
126
155
  id: e.string(),
127
156
  type: e.literal("root"),
128
157
  name: e.string(),
@@ -131,27 +160,51 @@ const i = ({ apiKey: n }) => r({
131
160
  color: e.string()
132
161
  }).readonly(),
133
162
  children: e.array(
134
- e.lazy(() => y)
163
+ e.lazy(() => v)
135
164
  ).readonly()
136
- }).readonly(), S = (n) => {
137
- const o = i({
165
+ }).readonly(), E = (n) => {
166
+ const o = y({
138
167
  apiKey: n.apiKey
139
- });
168
+ }), a = {}, t = d(
169
+ a
170
+ ), i = "", l = d(
171
+ i
172
+ );
140
173
  return {
141
- getEligibleCampaign: async () => {
142
- const t = await o.getEligibleCampaign.query();
143
- return t ? {
144
- ...t,
174
+ propertiesStore: t,
175
+ pathnameStore: l,
176
+ setProperties: (r) => {
177
+ t.set(r);
178
+ },
179
+ resetProperties: () => {
180
+ t.set(a);
181
+ },
182
+ setPathname: (r) => {
183
+ l.set(r);
184
+ },
185
+ resetPathname: () => {
186
+ l.set(i);
187
+ },
188
+ getEligibleCampaign: async ({
189
+ properties: r,
190
+ pathname: s
191
+ }) => {
192
+ const c = await o.getEligibleCampaign.query({
193
+ properties: r,
194
+ pathname: s
195
+ });
196
+ return {
197
+ ...c,
145
198
  template: {
146
- ...t.template,
199
+ ...c.template,
147
200
  // TODO: Do we need to parse the content here or on procedure level?
148
- content: h.parse(t.template.content)
201
+ content: w.parse(c.template.content)
149
202
  }
150
- } : null;
203
+ };
151
204
  }
152
205
  };
153
206
  };
154
207
  export {
155
- S as createBokoClient
208
+ E as createBokoClient
156
209
  };
157
210
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/client.ts","../../../node_modules/.pnpm/@truecodeio+domain-shared@0.1.7/node_modules/@truecodeio/domain-shared/src/schemas/tree-nodes/index.ts","../src/index.ts"],"sourcesContent":["import { createTRPCClient, httpBatchLink } from \"@trpc/client\";\nimport superjson from \"superjson\";\nimport type { AppRouter } from \"./app-router-types\";\n\ntype ClientConfig = {\n apiKey: string;\n};\n\nexport const createClient = ({ apiKey }: ClientConfig) => {\n return createTRPCClient<AppRouter>({\n links: [\n httpBatchLink({\n transformer: superjson,\n url: __SERVER_URL__,\n headers: () => {\n return {\n Authorization: `ApiKey ${apiKey}`,\n };\n },\n }),\n ],\n });\n};\n","import { z } from \"zod\";\n\nexport const spacerNodeSchema = z\n .object({\n id: z.string(),\n type: z.literal(\"spacer\"),\n name: z.string(),\n isCollapsed: z.boolean(),\n props: z\n .object({\n size: z.number(),\n })\n .readonly(),\n })\n .readonly();\n\nexport const textNodeSchema = z\n .object({\n id: z.string(),\n type: z.literal(\"text\"),\n name: z.string(),\n isCollapsed: z.boolean(),\n props: z\n .object({\n content: z.string(),\n })\n .readonly(),\n })\n .readonly();\n\nexport const imageNodeSchema = z\n .object({\n id: z.string(),\n type: z.literal(\"image\"),\n name: z.string(),\n isCollapsed: z.boolean(),\n props: z\n .discriminatedUnion(\"type\", [\n z.object({\n type: z.literal(\"placeholder\"),\n }),\n z.object({\n type: z.literal(\"image\"),\n url: z.string(),\n fileName: z.string(),\n altText: z.string(),\n width: z.number(),\n height: z.number(),\n preserveAspectRatio: z.boolean(),\n }),\n ])\n .readonly(),\n })\n .readonly();\n\nexport const buttonNodeSchema = z\n .object({\n id: z.string(),\n type: z.literal(\"button\"),\n name: z.string(),\n isCollapsed: z.boolean(),\n props: z\n .object({\n title: z.string(),\n background: z\n .object({\n color: z\n .object({\n default: z.string(),\n hover: z.string(),\n })\n .readonly(),\n })\n .readonly(),\n text: z\n .object({\n color: z\n .object({\n default: z.string(),\n hover: z.string(),\n })\n .readonly(),\n })\n .readonly(),\n padding: z\n .object({\n top: z.number(),\n right: z.number(),\n bottom: z.number(),\n left: z.number(),\n })\n .readonly(),\n borderRadius: z.number(),\n fontSize: z.number().min(8).max(72).default(16),\n fontWeight: z.number().min(100).max(900).multipleOf(100).default(400),\n })\n .readonly(),\n })\n .readonly();\n\nexport const flexChildSizeSchema = z.enum([\"default\", \"equal\", \"none\"]);\n\nexport const verticalAlignmentSchema = z.enum([\"start\", \"center\", \"end\"]);\n\nexport const columnNodeSchema = z\n .object({\n id: z.string(),\n type: z.literal(\"column\"),\n name: z.string(),\n isCollapsed: z.boolean(),\n props: z\n .object({\n flexChildSize: flexChildSizeSchema,\n alignment: z\n .object({\n vertical: verticalAlignmentSchema,\n })\n .readonly(),\n })\n .readonly(),\n children: z\n .array(\n z.lazy(() => {\n return z.union([\n buttonNodeSchema,\n textNodeSchema,\n spacerNodeSchema,\n imageNodeSchema,\n ]);\n }),\n )\n .readonly(),\n })\n .readonly();\n\nexport const horizontalAlignmentSchema = z.enum([\n \"default\",\n \"start\",\n \"center\",\n \"end\",\n]);\n\nexport const rowNodeSchema = z\n .object({\n id: z.string(),\n type: z.literal(\"row\"),\n name: z.string(),\n isCollapsed: z.boolean(),\n props: z\n .object({\n padding: z\n .object({\n top: z.number(),\n right: z.number(),\n bottom: z.number(),\n left: z.number(),\n })\n .readonly(),\n gap: z.number(),\n background: z\n .object({\n color: z.string(),\n })\n .readonly(),\n alignment: z\n .object({\n horizontal: horizontalAlignmentSchema,\n })\n .readonly(),\n })\n .readonly(),\n children: z\n .array(\n z.lazy(() => {\n return columnNodeSchema;\n }),\n )\n .readonly(),\n })\n .readonly();\n\nexport const rootNodeSchema = z\n .object({\n id: z.string(),\n type: z.literal(\"root\"),\n name: z.string(),\n isCollapsed: z.boolean(),\n props: z\n .object({\n color: z.string(),\n })\n .readonly(),\n children: z\n .array(\n z.lazy(() => {\n return rowNodeSchema;\n }),\n )\n .readonly(),\n })\n .readonly();\n\nexport type ButtonNodeT = z.infer<typeof buttonNodeSchema>;\n\nexport type RootNodeT = z.infer<typeof rootNodeSchema>;\n\nexport type RowNodeT = z.infer<typeof rowNodeSchema>;\n\nexport type ColumnNodeT = z.infer<typeof columnNodeSchema>;\n\nexport type TextNodeT = z.infer<typeof textNodeSchema>;\n\nexport type SpacerNodeT = z.infer<typeof spacerNodeSchema>;\n\nexport type ImageNodeT = z.infer<typeof imageNodeSchema>;\n\nexport type NodeT =\n | RootNodeT\n | RowNodeT\n | ColumnNodeT\n | ButtonNodeT\n | TextNodeT\n | SpacerNodeT\n | ImageNodeT;\n\ntype ChildrenNonContainableNodeT =\n | ButtonNodeT\n | TextNodeT\n | SpacerNodeT\n | ImageNodeT;\n\nexport type ChildrenContainableNodeT = Exclude<\n NodeT,\n ChildrenNonContainableNodeT\n>;\n\nexport type ChildrenNodeT = Exclude<NodeT, RootNodeT>;\n\nexport type NodeByTypeT = {\n [N in NodeT as N[\"type\"]]: N;\n};\n","import { createClient } from \"./client.ts\";\nimport { rootNodeSchema } from \"@truecodeio/domain-shared/schemas/tree-nodes/index.ts\";\n\ntype ClientOptions = {\n apiKey: string;\n};\n\nexport const createBokoClient = (options: ClientOptions) => {\n const client = createClient({\n apiKey: options.apiKey,\n });\n\n return {\n getEligibleCampaign: async () => {\n const eligibleCampaign = await client.getEligibleCampaign.query();\n\n if (!eligibleCampaign) {\n return null;\n }\n\n return {\n ...eligibleCampaign,\n template: {\n ...eligibleCampaign.template,\n // TODO: Do we need to parse the content here or on procedure level?\n content: rootNodeSchema.parse(eligibleCampaign.template.content),\n },\n };\n },\n };\n};\n\nexport type EligibleCampaign = NonNullable<\n Awaited<\n ReturnType<ReturnType<typeof createBokoClient>[\"getEligibleCampaign\"]>\n >\n>;\n"],"names":["createClient","apiKey","createTRPCClient","httpBatchLink","superjson","spacerNodeSchema","z","textNodeSchema","imageNodeSchema","buttonNodeSchema","flexChildSizeSchema","verticalAlignmentSchema","columnNodeSchema","horizontalAlignmentSchema","rowNodeSchema","rootNodeSchema","createBokoClient","options","client","eligibleCampaign"],"mappings":";;;AAQO,MAAMA,IAAe,CAAC,EAAE,QAAAC,QACtBC,EAA4B;AAAA,EACjC,OAAO;AAAA,IACLC,EAAc;AAAA,MACZ,aAAaC;AAAA,MACb,KAAK;AAAA,MACL,SAAS,OACA;AAAA,QACL,eAAe,UAAUH,CAAM;AAAA,MAAA;AAAA,IAEnC,CACD;AAAA,EAAA;AACH,CACD,GCnBUI,IAAmBC,EAC7B,OAAO;AAAA,EACN,IAAIA,EAAE,OAAA;AAAA,EACN,MAAMA,EAAE,QAAQ,QAAQ;AAAA,EACxB,MAAMA,EAAE,OAAA;AAAA,EACR,aAAaA,EAAE,QAAA;AAAA,EACf,OAAOA,EACJ,OAAO;AAAA,IACN,MAAMA,EAAE,OAAA;AAAA,EAAO,CAChB,EACA,SAAA;AACL,CAAC,EACA,SAAA,GAEUC,IAAiBD,EAC3B,OAAO;AAAA,EACN,IAAIA,EAAE,OAAA;AAAA,EACN,MAAMA,EAAE,QAAQ,MAAM;AAAA,EACtB,MAAMA,EAAE,OAAA;AAAA,EACR,aAAaA,EAAE,QAAA;AAAA,EACf,OAAOA,EACJ,OAAO;AAAA,IACN,SAASA,EAAE,OAAA;AAAA,EAAO,CACnB,EACA,SAAA;AACL,CAAC,EACA,SAAA,GAEUE,IAAkBF,EAC5B,OAAO;AAAA,EACN,IAAIA,EAAE,OAAA;AAAA,EACN,MAAMA,EAAE,QAAQ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,MACP,OAAOA,EAAE,OAAA;AAAA,MACT,QAAQA,EAAE,OAAA;AAAA,MACV,MAAMA,EAAE,OAAA;AAAA,IAAO,CAChB,EACA,SAAA;AAAA,IACH,KAAKA,EAAE,OAAA;AAAA,IACP,YAAYA,EACT,OAAO;AAAA,MACN,OAAOA,EAAE,OAAA;AAAA,IAAO,CACjB,EACA,SAAA;AAAA,IACH,WAAWA,EACR,OAAO;AAAA,MACN,YAAYO;AAAA,IAAA,CACb,EACA,SAAA;AAAA,EAAS,CACb,EACA,SAAA;AAAA,EACH,UAAUP,EACP;AAAA,IACCA,EAAE,KAAK,MACEM,CACR;AAAA,EAAA,EAEF,SAAA;AACL,CAAC,EACA,SAAA,GAEUG,IAAiBT,EAC3B,OAAO;AAAA,EACN,IAAIA,EAAE,OAAA;AAAA,EACN,MAAMA,EAAE,QAAQ,MAAM;AAAA,EACtB,MAAMA,EAAE,OAAA;AAAA,EACR,aAAaA,EAAE,QAAA;AAAA,EACf,OAAOA,EACJ,OAAO;AAAA,IACN,OAAOA,EAAE,OAAA;AAAA,EAAO,CACjB,EACA,SAAA;AAAA,EACH,UAAUA,EACP;AAAA,IACCA,EAAE,KAAK,MACEQ,CACR;AAAA,EAAA,EAEF,SAAA;AACL,CAAC,EACA,SAAA,GCjMUE,IAAmB,CAACC,MAA2B;AAC1D,QAAMC,IAASlB,EAAa;AAAA,IAC1B,QAAQiB,EAAQ;AAAA,EAAA,CACjB;AAED,SAAO;AAAA,IACL,qBAAqB,YAAY;AAC/B,YAAME,IAAmB,MAAMD,EAAO,oBAAoB,MAAA;AAE1D,aAAKC,IAIE;AAAA,QACL,GAAGA;AAAA,QACH,UAAU;AAAA,UACR,GAAGA,EAAiB;AAAA;AAAA,UAEpB,SAASJ,EAAe,MAAMI,EAAiB,SAAS,OAAO;AAAA,QAAA;AAAA,MACjE,IATO;AAAA,IAUT;AAAA,EACF;AAEJ;","x_google_ignoreList":[1]}
1
+ {"version":3,"file":"index.js","sources":["../../common/src/common/emitter/create-emitter.ts","../../common/src/common/store/create-store.ts","../src/client.ts","../../domain-shared/src/schemas/tree-nodes/index.ts","../src/index.ts"],"sourcesContent":["export type SubscriberT<ActionT> = (action: ActionT) => void;\n\nexport type SubscribeT<ActionT> = (\n subscriber: SubscriberT<ActionT>,\n) => () => void;\n\nexport type DispatchT<ActionT> = (action: ActionT) => void;\n\nexport type EmitterT<ActionT> = {\n dispatch: DispatchT<ActionT>;\n subscribe: SubscribeT<ActionT>;\n};\n\nexport const createEmitter = <ActionT>(): EmitterT<ActionT> => {\n const subscribers = new Set<SubscriberT<ActionT>>();\n\n const dispatch: DispatchT<ActionT> = (action) => {\n for (const subscriber of subscribers) {\n subscriber(action);\n }\n };\n\n const subscribe: SubscribeT<ActionT> = (subscriber) => {\n subscribers.add(subscriber);\n\n return () => {\n subscribers.delete(subscriber);\n };\n };\n\n return {\n dispatch,\n subscribe,\n };\n};\n","import { createEmitter } from \"../emitter/create-emitter.ts\";\n\nexport type SetStateAction<S> = S | ((previousState: S) => S);\n\ntype Dispatch<A> = (value: A) => void;\n\nexport type StoreT<ValueT> = {\n get: () => ValueT;\n subscribe: (subscriber: (value: ValueT) => void) => () => void;\n set: Dispatch<SetStateAction<ValueT>>;\n};\n\nconst setStateReducer = <StateT>(\n state: StateT,\n action: SetStateAction<StateT>,\n): StateT => {\n if (typeof action === \"function\") {\n const function_ = action as (state: StateT) => StateT;\n\n return function_(state);\n }\n\n return action;\n};\n\nexport const createStore = <ValueT>(initialValue: ValueT): StoreT<ValueT> => {\n const { subscribe, dispatch } = createEmitter<ValueT>();\n\n let value = initialValue;\n\n const get = (): ValueT => {\n return value;\n };\n\n const set = (action: SetStateAction<ValueT>): void => {\n const nextValue = setStateReducer<ValueT>(value, action);\n\n if (nextValue === value) {\n return;\n }\n\n value = nextValue;\n\n dispatch(value);\n };\n\n return {\n get,\n set,\n subscribe,\n };\n};\n","import { createTRPCClient, httpBatchLink } from \"@trpc/client\";\nimport superjson from \"superjson\";\nimport type { AppRouter } from \"./app-router-types\";\n\ntype ClientConfig = {\n apiKey: string;\n};\n\nexport const createClient = ({ apiKey }: ClientConfig) => {\n return createTRPCClient<AppRouter>({\n links: [\n httpBatchLink({\n transformer: superjson,\n url: __SERVER_URL__,\n headers: () => {\n return {\n Authorization: `ApiKey ${apiKey}`,\n };\n },\n }),\n ],\n });\n};\n","import { z } from \"zod\";\n\nexport const spacerNodeSchema = z\n .object({\n id: z.string(),\n type: z.literal(\"spacer\"),\n name: z.string(),\n isCollapsed: z.boolean(),\n props: z\n .object({\n size: z.number(),\n })\n .readonly(),\n })\n .readonly();\n\nexport const textNodeSchema = z\n .object({\n id: z.string(),\n type: z.literal(\"text\"),\n name: z.string(),\n isCollapsed: z.boolean(),\n props: z\n .object({\n content: z.string(),\n })\n .readonly(),\n })\n .readonly();\n\nexport const imageNodeSchema = z\n .object({\n id: z.string(),\n type: z.literal(\"image\"),\n name: z.string(),\n isCollapsed: z.boolean(),\n props: z\n .discriminatedUnion(\"type\", [\n z.object({\n type: z.literal(\"placeholder\"),\n }),\n z.object({\n type: z.literal(\"image\"),\n url: z.string(),\n fileName: z.string(),\n altText: z.string(),\n width: z.number(),\n height: z.number(),\n preserveAspectRatio: z.boolean(),\n }),\n ])\n .readonly(),\n })\n .readonly();\n\nexport const customComponentSchema = z\n .object({\n id: z.string(),\n type: z.literal(\"custom-component\"),\n name: z.string(),\n isCollapsed: z.boolean(),\n componentId: z.string(),\n })\n .readonly();\n\nexport const buttonNodeSchema = z\n .object({\n id: z.string(),\n type: z.literal(\"button\"),\n name: z.string(),\n isCollapsed: z.boolean(),\n props: z\n .object({\n title: z.string(),\n background: z\n .object({\n color: z\n .object({\n default: z.string(),\n hover: z.string(),\n })\n .readonly(),\n })\n .readonly(),\n text: z\n .object({\n color: z\n .object({\n default: z.string(),\n hover: z.string(),\n })\n .readonly(),\n })\n .readonly(),\n padding: z\n .object({\n top: z.number(),\n right: z.number(),\n bottom: z.number(),\n left: z.number(),\n })\n .readonly(),\n borderRadius: z.number(),\n fontSize: z.number().min(8).max(72).default(16),\n fontWeight: z.number().min(100).max(900).multipleOf(100).default(400),\n })\n .readonly(),\n })\n .readonly();\n\nexport const flexChildSizeSchema = z.enum([\"default\", \"equal\", \"none\"]);\n\nexport const verticalAlignmentSchema = z.enum([\"start\", \"center\", \"end\"]);\n\nexport const columnNodeSchema = z\n .object({\n id: z.string(),\n type: z.literal(\"column\"),\n name: z.string(),\n isCollapsed: z.boolean(),\n props: z\n .object({\n flexChildSize: flexChildSizeSchema,\n alignment: z\n .object({\n vertical: verticalAlignmentSchema,\n })\n .readonly(),\n })\n .readonly(),\n children: z\n .array(\n z.lazy(() => {\n return z.union([\n buttonNodeSchema,\n textNodeSchema,\n spacerNodeSchema,\n imageNodeSchema,\n customComponentSchema,\n ]);\n }),\n )\n .readonly(),\n })\n .readonly();\n\nexport const horizontalAlignmentSchema = z.enum([\n \"default\",\n \"start\",\n \"center\",\n \"end\",\n]);\n\nexport const rowNodeSchema = z\n .object({\n id: z.string(),\n type: z.literal(\"row\"),\n name: z.string(),\n isCollapsed: z.boolean(),\n props: z\n .object({\n padding: z\n .object({\n top: z.number(),\n right: z.number(),\n bottom: z.number(),\n left: z.number(),\n })\n .readonly(),\n gap: z.number(),\n background: z\n .object({\n color: z.string(),\n })\n .readonly(),\n alignment: z\n .object({\n horizontal: horizontalAlignmentSchema,\n })\n .readonly(),\n })\n .readonly(),\n children: z\n .array(\n z.lazy(() => {\n return columnNodeSchema;\n }),\n )\n .readonly(),\n })\n .readonly();\n\nexport const rootNodeSchema = z\n .object({\n id: z.string(),\n type: z.literal(\"root\"),\n name: z.string(),\n isCollapsed: z.boolean(),\n props: z\n .object({\n color: z.string(),\n })\n .readonly(),\n children: z\n .array(\n z.lazy(() => {\n return rowNodeSchema;\n }),\n )\n .readonly(),\n })\n .readonly();\n\nexport type ButtonNodeT = z.infer<typeof buttonNodeSchema>;\n\nexport type RootNodeT = z.infer<typeof rootNodeSchema>;\n\nexport type RowNodeT = z.infer<typeof rowNodeSchema>;\n\nexport type ColumnNodeT = z.infer<typeof columnNodeSchema>;\n\nexport type TextNodeT = z.infer<typeof textNodeSchema>;\n\nexport type SpacerNodeT = z.infer<typeof spacerNodeSchema>;\n\nexport type ImageNodeT = z.infer<typeof imageNodeSchema>;\n\nexport type CustomComponentNodeT = z.infer<typeof customComponentSchema>;\n\nexport type NodeT =\n | RootNodeT\n | RowNodeT\n | ColumnNodeT\n | ButtonNodeT\n | TextNodeT\n | SpacerNodeT\n | ImageNodeT\n | CustomComponentNodeT;\n\ntype ChildrenNonContainableNodeT =\n | ButtonNodeT\n | TextNodeT\n | SpacerNodeT\n | ImageNodeT\n | CustomComponentNodeT;\n\nexport type ChildrenContainableNodeT = Exclude<\n NodeT,\n ChildrenNonContainableNodeT\n>;\n\nexport type ChildrenNodeT = Exclude<NodeT, RootNodeT>;\n\nexport type NodeByTypeT = {\n [N in NodeT as N[\"type\"]]: N;\n};\n","import {\n createStore,\n type SetStateAction,\n} from \"@truecodeio/common/common/store/create-store.ts\";\nimport { createClient } from \"./client.ts\";\nimport { rootNodeSchema } from \"@truecodeio/domain-shared/schemas/tree-nodes/index.ts\";\n\ntype ClientOptions = {\n apiKey: string;\n};\n\ntype Properties = Record<string, boolean | string | number>;\n\ntype PropertiesStoreValue = Properties;\n\ntype Pathname = string;\n\ntype PathnameStoreValue = Pathname;\n\nexport const createBokoClient = (options: ClientOptions) => {\n const client = createClient({\n apiKey: options.apiKey,\n });\n\n const propertiesStoreInitialValue = {};\n\n const propertiesStore = createStore<PropertiesStoreValue>(\n propertiesStoreInitialValue,\n );\n\n const pathnameStoreInitialValue = \"\";\n\n const pathnameStore = createStore<PathnameStoreValue>(\n pathnameStoreInitialValue,\n );\n\n return {\n propertiesStore,\n pathnameStore,\n setProperties: (action: SetStateAction<PropertiesStoreValue>) => {\n propertiesStore.set(action);\n },\n resetProperties: () => {\n propertiesStore.set(propertiesStoreInitialValue);\n },\n setPathname: (action: SetStateAction<PathnameStoreValue>) => {\n pathnameStore.set(action);\n },\n resetPathname: () => {\n pathnameStore.set(pathnameStoreInitialValue);\n },\n getEligibleCampaign: async ({\n properties,\n pathname,\n }: {\n properties: Properties;\n pathname: string;\n }) => {\n const eligibleCampaign = await client.getEligibleCampaign.query({\n properties,\n pathname,\n });\n\n return {\n ...eligibleCampaign,\n template: {\n ...eligibleCampaign.template,\n // TODO: Do we need to parse the content here or on procedure level?\n content: rootNodeSchema.parse(eligibleCampaign.template.content),\n },\n };\n },\n };\n};\n\nexport type EligibleCampaign = NonNullable<\n Awaited<\n ReturnType<ReturnType<typeof createBokoClient>[\"getEligibleCampaign\"]>\n >\n>;\n"],"names":["createEmitter","subscribers","action","subscriber","setStateReducer","state","createStore","initialValue","subscribe","dispatch","value","nextValue","createClient","apiKey","createTRPCClient","httpBatchLink","superjson","spacerNodeSchema","z","textNodeSchema","imageNodeSchema","customComponentSchema","buttonNodeSchema","flexChildSizeSchema","verticalAlignmentSchema","columnNodeSchema","horizontalAlignmentSchema","rowNodeSchema","rootNodeSchema","createBokoClient","options","client","propertiesStoreInitialValue","propertiesStore","pathnameStoreInitialValue","pathnameStore","properties","pathname","eligibleCampaign"],"mappings":";;;AAaO,MAAMA,IAAgB,MAAkC;AAC7D,QAAMC,wBAAkB,IAAA;AAgBxB,SAAO;AAAA,IACL,UAfmC,CAACC,MAAW;AAC/C,iBAAWC,KAAcF;AACvB,QAAAE,EAAWD,CAAM;AAAA,IAErB;AAAA,IAYE,WAVqC,CAACC,OACtCF,EAAY,IAAIE,CAAU,GAEnB,MAAM;AACX,MAAAF,EAAY,OAAOE,CAAU;AAAA,IAC/B;AAAA,EAKA;AAEJ,GCtBMC,IAAkB,CACtBC,GACAH,MAEI,OAAOA,KAAW,aACFA,EAEDG,CAAK,IAGjBH,GAGII,IAAc,CAASC,MAAyC;AAC3E,QAAM,EAAE,WAAAC,GAAW,UAAAC,EAAA,IAAaT,EAAA;AAEhC,MAAIU,IAAQH;AAkBZ,SAAO;AAA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IAAID,CAA2B;AAAA,IACjD;AAAA,IACA,aAAa,CAAC9B,MAA+C;AAC3D,MAAAiC,EAAc,IAAIjC,CAAM;AAAA,IAC1B;AAAA,IACA,eAAe,MAAM;AACnB,MAAAiC,EAAc,IAAID,CAAyB;AAAA,IAC7C;AAAA,IACA,qBAAqB,OAAO;AAAA,MAC1B,YAAAE;AAAA,MACA,UAAAC;AAAA,IAAA,MAII;AACJ,YAAMC,IAAmB,MAAMP,EAAO,oBAAoB,MAAM;AAAA,QAC9D,YAAAK;AAAA,QACA,UAAAC;AAAA,MAAA,CACD;AAED,aAAO;AAAA,QACL,GAAGC;AAAA,QACH,UAAU;AAAA,UACR,GAAGA,EAAiB;AAAA;AAAA,UAEpB,SAASV,EAAe,MAAMU,EAAiB,SAAS,OAAO;AAAA,QAAA;AAAA,MACjE;AAAA,IAEJ;AAAA,EAAA;AAEJ;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truecodeio/sdk-core",
3
- "version": "0.2.10",
3
+ "version": "0.2.12",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -12,21 +12,23 @@
12
12
  "dist"
13
13
  ],
14
14
  "dependencies": {
15
- "@trpc/client": "^11.4.4",
16
- "@trpc/server": "^11.4.4",
17
- "@truecodeio/domain-shared": "^0.1.7",
18
- "superjson": "^2.2.2",
19
- "zod": "^4.0.17"
15
+ "@trpc/client": "^11.7.1",
16
+ "@trpc/server": "^11.7.1",
17
+ "superjson": "^2.2.5",
18
+ "zod": "^4.1.12",
19
+ "@truecodeio/common": "0.1.5",
20
+ "@truecodeio/domain-shared": "0.1.8"
20
21
  },
21
22
  "devDependencies": {
22
- "typescript-eslint": "^8.39.1",
23
- "vite": "^7.1.2",
23
+ "typescript-eslint": "^8.46.4",
24
+ "vite": "^7.2.2",
24
25
  "vite-plugin-dts": "^4.5.4",
25
- "@boko/eslint-config": "1.0.0",
26
- "@boko/tsconfig": "^1.0.0"
26
+ "@boko/tsconfig": "^1.0.0",
27
+ "@boko/eslint-config": "1.0.0"
27
28
  },
28
29
  "scripts": {
29
30
  "build": "vite build",
31
+ "build:watch": "vite build --watch --mode development",
30
32
  "format:prettier:fix:all": "prettier --cache --write ./src",
31
33
  "lint:eslint:fix:all": "eslint --cache --fix ./src",
32
34
  "lint:typescript": "tsc --noEmit"