@truecodeio/sdk-core 0.2.9 → 0.2.11

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
  }>;
@@ -148,13 +220,13 @@ declare const appRouter: import('@trpc/server').TRPCBuiltRouter<{
148
220
  content: unknown;
149
221
  createdBy: string;
150
222
  status: string;
151
- } | undefined;
223
+ };
152
224
  meta: object;
153
225
  }>;
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,45 @@ declare const appRouter: import('@trpc/server').TRPCBuiltRouter<{
222
504
  updatedAt: Date;
223
505
  status: string;
224
506
  };
225
- } | null;
507
+ };
508
+ meta: object;
509
+ }>;
510
+ generateImageUploadUrl: import('@trpc/server').TRPCMutationProcedure<{
511
+ input: {
512
+ templateId: string;
513
+ fileName: string;
514
+ fileSize: number;
515
+ fileType: string;
516
+ };
517
+ output: {
518
+ uploadUrl: string;
519
+ path: string;
520
+ fileName: string;
521
+ };
522
+ meta: object;
523
+ }>;
524
+ confirmImageUpload: import('@trpc/server').TRPCMutationProcedure<{
525
+ input: {
526
+ path: string;
527
+ fileName: string;
528
+ originalFileName: string;
529
+ };
530
+ output: {
531
+ url: string;
532
+ path: string;
533
+ fileName: string;
534
+ originalFileName: string;
535
+ };
536
+ meta: object;
537
+ }>;
538
+ deleteImage: import('@trpc/server').TRPCMutationProcedure<{
539
+ input: {
540
+ templateId: string;
541
+ fileName: string;
542
+ };
543
+ output: {
544
+ success: boolean;
545
+ };
226
546
  meta: object;
227
547
  }>;
228
548
  }>>;
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
  }>;
@@ -151,13 +223,13 @@ export declare const createClient: ({ apiKey }: ClientConfig) => import('@trpc/c
151
223
  content: unknown;
152
224
  createdBy: string;
153
225
  status: string;
154
- } | undefined;
226
+ };
155
227
  meta: object;
156
228
  }>;
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,45 @@ export declare const createClient: ({ apiKey }: ClientConfig) => import('@trpc/c
225
507
  updatedAt: Date;
226
508
  status: string;
227
509
  };
228
- } | null;
510
+ };
511
+ meta: object;
512
+ }>;
513
+ generateImageUploadUrl: import('@trpc/server').TRPCMutationProcedure<{
514
+ input: {
515
+ templateId: string;
516
+ fileName: string;
517
+ fileSize: number;
518
+ fileType: string;
519
+ };
520
+ output: {
521
+ uploadUrl: string;
522
+ path: string;
523
+ fileName: string;
524
+ };
525
+ meta: object;
526
+ }>;
527
+ confirmImageUpload: import('@trpc/server').TRPCMutationProcedure<{
528
+ input: {
529
+ path: string;
530
+ fileName: string;
531
+ originalFileName: string;
532
+ };
533
+ output: {
534
+ url: string;
535
+ path: string;
536
+ fileName: string;
537
+ originalFileName: string;
538
+ };
539
+ meta: object;
540
+ }>;
541
+ deleteImage: import('@trpc/server').TRPCMutationProcedure<{
542
+ input: {
543
+ templateId: string;
544
+ fileName: string;
545
+ };
546
+ output: {
547
+ success: boolean;
548
+ };
229
549
  meta: object;
230
550
  }>;
231
551
  }>>>;
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;
@@ -58,8 +72,29 @@ export declare const createBokoClient: (options: ClientOptions) => {
58
72
  isCollapsed: boolean;
59
73
  props: Readonly<{
60
74
  content: string;
61
- type: "paragraph" | "heading-1" | "heading-2" | "heading-3" | "heading-4" | "heading-5" | "heading-6";
62
75
  }>;
76
+ }> | Readonly<{
77
+ id: string;
78
+ type: "image";
79
+ name: string;
80
+ isCollapsed: boolean;
81
+ props: Readonly<{
82
+ type: "placeholder";
83
+ }> | Readonly<{
84
+ type: "image";
85
+ url: string;
86
+ fileName: string;
87
+ altText: string;
88
+ width: number;
89
+ height: number;
90
+ preserveAspectRatio: boolean;
91
+ }>;
92
+ }> | Readonly<{
93
+ id: string;
94
+ type: "custom-component";
95
+ name: string;
96
+ isCollapsed: boolean;
97
+ componentId: string;
63
98
  }> | Readonly<{
64
99
  id: string;
65
100
  type: "button";
@@ -102,7 +137,7 @@ export declare const createBokoClient: (options: ClientOptions) => {
102
137
  status: string;
103
138
  };
104
139
  id: string;
105
- } | null>;
140
+ }>;
106
141
  };
107
142
  export type EligibleCampaign = NonNullable<Awaited<ReturnType<ReturnType<typeof createBokoClient>["getEligibleCampaign"]>>>;
108
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
- }), d = e.object({
36
+ }), h = e.object({
15
37
  id: e.string(),
16
38
  type: e.literal("spacer"),
17
39
  name: e.string(),
@@ -19,24 +41,40 @@ const i = ({ apiKey: n }) => r({
19
41
  props: e.object({
20
42
  size: e.number()
21
43
  }).readonly()
22
- }).readonly(), c = e.object({
44
+ }).readonly(), f = e.object({
23
45
  id: e.string(),
24
46
  type: e.literal("text"),
25
47
  name: e.string(),
26
48
  isCollapsed: e.boolean(),
27
49
  props: e.object({
28
- content: e.string(),
29
- type: e.enum([
30
- "paragraph",
31
- "heading-1",
32
- "heading-2",
33
- "heading-3",
34
- "heading-4",
35
- "heading-5",
36
- "heading-6"
37
- ])
50
+ content: e.string()
38
51
  }).readonly()
39
- }).readonly(), s = e.object({
52
+ }).readonly(), j = e.object({
53
+ id: e.string(),
54
+ type: e.literal("image"),
55
+ name: e.string(),
56
+ isCollapsed: e.boolean(),
57
+ props: e.discriminatedUnion("type", [
58
+ e.object({
59
+ type: e.literal("placeholder")
60
+ }),
61
+ e.object({
62
+ type: e.literal("image"),
63
+ url: e.string(),
64
+ fileName: e.string(),
65
+ altText: e.string(),
66
+ width: e.number(),
67
+ height: e.number(),
68
+ preserveAspectRatio: e.boolean()
69
+ })
70
+ ]).readonly()
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({
40
78
  id: e.string(),
41
79
  type: e.literal("button"),
42
80
  name: e.string(),
@@ -65,26 +103,32 @@ const i = ({ apiKey: n }) => r({
65
103
  fontSize: e.number().min(8).max(72).default(16),
66
104
  fontWeight: e.number().min(100).max(900).multipleOf(100).default(400)
67
105
  }).readonly()
68
- }).readonly(), m = e.enum(["default", "equal", "none"]), p = e.enum(["start", "center", "end"]), b = e.object({
106
+ }).readonly(), z = e.enum(["default", "equal", "none"]), x = e.enum(["start", "center", "end"]), N = e.object({
69
107
  id: e.string(),
70
108
  type: e.literal("column"),
71
109
  name: e.string(),
72
110
  isCollapsed: e.boolean(),
73
111
  props: e.object({
74
- flexChildSize: m,
112
+ flexChildSize: z,
75
113
  alignment: e.object({
76
- vertical: p
114
+ vertical: x
77
115
  }).readonly()
78
116
  }).readonly(),
79
117
  children: e.array(
80
- e.lazy(() => e.union([s, c, d]))
118
+ e.lazy(() => e.union([
119
+ C,
120
+ f,
121
+ h,
122
+ j,
123
+ S
124
+ ]))
81
125
  ).readonly()
82
- }).readonly(), g = e.enum([
126
+ }).readonly(), k = e.enum([
83
127
  "default",
84
128
  "start",
85
129
  "center",
86
130
  "end"
87
- ]), u = e.object({
131
+ ]), v = e.object({
88
132
  id: e.string(),
89
133
  type: e.literal("row"),
90
134
  name: e.string(),
@@ -101,13 +145,13 @@ const i = ({ apiKey: n }) => r({
101
145
  color: e.string()
102
146
  }).readonly(),
103
147
  alignment: e.object({
104
- horizontal: g
148
+ horizontal: k
105
149
  }).readonly()
106
150
  }).readonly(),
107
151
  children: e.array(
108
- e.lazy(() => b)
152
+ e.lazy(() => N)
109
153
  ).readonly()
110
- }).readonly(), y = e.object({
154
+ }).readonly(), w = e.object({
111
155
  id: e.string(),
112
156
  type: e.literal("root"),
113
157
  name: e.string(),
@@ -116,27 +160,51 @@ const i = ({ apiKey: n }) => r({
116
160
  color: e.string()
117
161
  }).readonly(),
118
162
  children: e.array(
119
- e.lazy(() => u)
163
+ e.lazy(() => v)
120
164
  ).readonly()
121
- }).readonly(), C = (n) => {
122
- const o = i({
165
+ }).readonly(), E = (n) => {
166
+ const o = y({
123
167
  apiKey: n.apiKey
124
- });
168
+ }), a = {}, t = d(
169
+ a
170
+ ), i = "", l = d(
171
+ i
172
+ );
125
173
  return {
126
- getEligibleCampaign: async () => {
127
- const t = await o.getEligibleCampaign.query();
128
- return t ? {
129
- ...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,
130
198
  template: {
131
- ...t.template,
199
+ ...c.template,
132
200
  // TODO: Do we need to parse the content here or on procedure level?
133
- content: y.parse(t.template.content)
201
+ content: w.parse(c.template.content)
134
202
  }
135
- } : null;
203
+ };
136
204
  }
137
205
  };
138
206
  };
139
207
  export {
140
- C as createBokoClient
208
+ E as createBokoClient
141
209
  };
142
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.6/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 type: z.enum([\n \"paragraph\",\n \"heading-1\",\n \"heading-2\",\n \"heading-3\",\n \"heading-4\",\n \"heading-5\",\n \"heading-6\",\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([buttonNodeSchema, textNodeSchema, spacerNodeSchema]);\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 NodeT =\n | RootNodeT\n | RowNodeT\n | ColumnNodeT\n | ButtonNodeT\n | TextNodeT\n | SpacerNodeT;\n\ntype ChildrenNonContainableNodeT = ButtonNodeT | TextNodeT | SpacerNodeT;\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","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;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IACCA,EAAE,KAAK,MACEK,CACR;AAAA,EAAA,EAEF,SAAA;AACL,CAAC,EACA,SAAA,GAEUG,IAAiBR,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,MACEO,CACR;AAAA,EAAA,EAEF,SAAA;AACL,CAAC,EACA,SAAA,GC5KUE,IAAmB,CAACC,MAA2B;AAC1D,QAAMC,IAASjB,EAAa;AAAA,IAC1B,QAAQgB,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;AAAA,IACL,KAjBU,MACHG;AAAA,IAiBP,KAdU,CAACR,MAAyC;AACpD,YAAMS,IAAYP,EAAwBM,GAAOR,CAAM;AAEvD,MAAIS,MAAcD,MAIlBA,IAAQC,GAERF,EAASC,CAAK;AAAA,IAChB;AAAA,IAKE,WAAAF;AAAA,EAAA;AAEJ,GC3CaI,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,UAAU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,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.9",
3
+ "version": "0.2.11",
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.3",
16
- "@trpc/server": "^11.4.3",
17
- "@truecodeio/domain-shared": "^0.1.6",
18
- "superjson": "^2.2.2",
19
- "zod": "^4.0.10"
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.7"
20
21
  },
21
22
  "devDependencies": {
22
- "typescript-eslint": "^8.38.0",
23
- "vite": "^7.0.6",
23
+ "typescript-eslint": "^8.46.4",
24
+ "vite": "^7.2.2",
24
25
  "vite-plugin-dts": "^4.5.4",
25
26
  "@boko/tsconfig": "^1.0.0",
26
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"