@deliverart/sdk-js-receipt-template 2.25.1 → 2.26.0

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.
package/README.md CHANGED
@@ -26,3 +26,7 @@ const updated = await sdk.call(
26
26
  ```
27
27
 
28
28
  `UpdateReceiptTemplate` emits `application/merge-patch+json` and a strong `If-Match` header. A stale revision is rejected by the API instead of silently overwriting a newer edit.
29
+
30
+ Time, customer, address, and note blocks support `fieldLayout: "inline" | "stacked"`. Existing definitions default to `inline`. In stacked mode, `labelStyle` controls each field heading while `style` independently controls its value; stacked layout is rejected for other block types.
31
+
32
+ `order_times` blocks support `showDate: false` when a receipt should print only the localized time. Missing or `null` values retain the legacy date-and-time format. The option is rejected on every other block type.
package/dist/index.cjs CHANGED
@@ -37,6 +37,8 @@ __export(index_exports, {
37
37
  receiptTemplateConditionTypeSchema: () => receiptTemplateConditionTypeSchema,
38
38
  receiptTemplateConditionTypes: () => receiptTemplateConditionTypes,
39
39
  receiptTemplateDefinitionSchema: () => receiptTemplateDefinitionSchema,
40
+ receiptTemplateFieldLayoutBlockTypes: () => receiptTemplateFieldLayoutBlockTypes,
41
+ receiptTemplateFieldLayoutSchema: () => receiptTemplateFieldLayoutSchema,
40
42
  receiptTemplateFieldSchema: () => receiptTemplateFieldSchema,
41
43
  receiptTemplateFields: () => receiptTemplateFields,
42
44
  receiptTemplateIriSchema: () => receiptTemplateIriSchema,
@@ -122,6 +124,13 @@ var receiptTemplateFields = [
122
124
  var receiptTemplateFieldSchema = import_zod.z.enum(receiptTemplateFields);
123
125
  var receiptTemplateAlignmentSchema = import_zod.z.enum(["left", "center", "right"]);
124
126
  var receiptTemplateTextSizeSchema = import_zod.z.enum(["normal", "tall", "double", "double_tall"]);
127
+ var receiptTemplateFieldLayoutSchema = import_zod.z.enum(["inline", "stacked"]);
128
+ var receiptTemplateFieldLayoutBlockTypes = [
129
+ "order_times",
130
+ "customer",
131
+ "address",
132
+ "notes"
133
+ ];
125
134
  var receiptTemplateTextSegmentTypeSchema = import_zod.z.enum(["literal", "field"]);
126
135
  var localizedTextSchema = import_zod.z.record(import_zod.z.string().regex(/^[a-z]{2}(?:_[A-Z]{2})?$/), import_zod.z.string().max(500)).refine((value) => Object.keys(value).length <= 16, "At most 16 translations are allowed");
127
136
  var receiptTemplateConditionSchema = import_zod.z.object({
@@ -167,6 +176,17 @@ var receiptTemplateBlockStyleSchema = import_zod.z.object({
167
176
  underline: import_zod.z.boolean(),
168
177
  inverse: import_zod.z.boolean()
169
178
  });
179
+ var defaultReceiptTemplateBlockStyle = {
180
+ alignment: "left",
181
+ size: "normal",
182
+ bold: false,
183
+ underline: false,
184
+ inverse: false
185
+ };
186
+ var defaultReceiptTemplateLabelStyle = {
187
+ ...defaultReceiptTemplateBlockStyle,
188
+ bold: true
189
+ };
170
190
  var receiptTemplateTextSegmentSchema = import_zod.z.object({
171
191
  type: receiptTemplateTextSegmentTypeSchema,
172
192
  translations: localizedTextSchema,
@@ -210,8 +230,11 @@ var receiptTemplateBlockSchema = import_zod.z.object({
210
230
  enabled: import_zod.z.boolean(),
211
231
  condition: receiptTemplateConditionSchema,
212
232
  style: receiptTemplateBlockStyleSchema,
233
+ labelStyle: receiptTemplateBlockStyleSchema.default(defaultReceiptTemplateLabelStyle),
234
+ fieldLayout: receiptTemplateFieldLayoutSchema.default("inline"),
213
235
  labels: localizedTextSchema,
214
236
  visibleFields: import_zod.z.array(receiptTemplateFieldSchema).max(32),
237
+ showDate: import_zod.z.boolean().nullable().optional(),
215
238
  spacerLines: import_zod.z.number().int().min(1).max(10).nullable(),
216
239
  separatorCharacter: import_zod.z.string().length(1).nullable(),
217
240
  segments: import_zod.z.array(receiptTemplateTextSegmentSchema).max(32)
@@ -237,6 +260,22 @@ var receiptTemplateBlockSchema = import_zod.z.object({
237
260
  message: "Segments are required only for custom text blocks"
238
261
  });
239
262
  }
263
+ if (block.fieldLayout !== "inline" && !receiptTemplateFieldLayoutBlockTypes.includes(
264
+ block.type
265
+ )) {
266
+ context.addIssue({
267
+ code: "custom",
268
+ path: ["fieldLayout"],
269
+ message: "Stacked field layout is supported only for times, customer, address and notes"
270
+ });
271
+ }
272
+ if (block.type !== "order_times" && block.showDate != null) {
273
+ context.addIssue({
274
+ code: "custom",
275
+ path: ["showDate"],
276
+ message: "showDate is supported only for order time blocks"
277
+ });
278
+ }
240
279
  });
241
280
  var repeatableBlockTypes = /* @__PURE__ */ new Set([
242
281
  "separator",
@@ -435,6 +474,8 @@ var receiptTemplateNullableIriSchema = (0, import_sdk_js_global_types3.iriNullab
435
474
  receiptTemplateConditionTypeSchema,
436
475
  receiptTemplateConditionTypes,
437
476
  receiptTemplateDefinitionSchema,
477
+ receiptTemplateFieldLayoutBlockTypes,
478
+ receiptTemplateFieldLayoutSchema,
438
479
  receiptTemplateFieldSchema,
439
480
  receiptTemplateFields,
440
481
  receiptTemplateIriSchema,