@contractspec/example.service-business-os 3.7.6 → 3.7.7

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/dist/index.js CHANGED
@@ -68,117 +68,74 @@ var CreateClientContract = defineCommand({
68
68
  ]
69
69
  }
70
70
  });
71
- // src/quote/quote.schema.ts
71
+ // src/invoice/invoice.schema.ts
72
72
  import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
73
- var QuoteModel = defineSchemaModel2({
74
- name: "Quote",
75
- description: "Quote/proposal",
73
+ var InvoiceModel = defineSchemaModel2({
74
+ name: "Invoice",
75
+ description: "Invoice issued for a job",
76
76
  fields: {
77
77
  id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
78
- clientId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
79
- title: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
80
- description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
78
+ jobId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
79
+ invoiceNumber: {
80
+ type: ScalarTypeEnum2.String_unsecure(),
81
+ isOptional: false
82
+ },
81
83
  amount: { type: ScalarTypeEnum2.Float_unsecure(), isOptional: false },
82
84
  currency: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
83
85
  status: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
84
- validUntil: { type: ScalarTypeEnum2.DateTime(), isOptional: true },
85
- createdAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
86
- }
87
- });
88
- var CreateQuoteInputModel = defineSchemaModel2({
89
- name: "CreateQuoteInput",
90
- description: "Input for creating a quote",
91
- fields: {
92
- clientId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
93
- title: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
94
- description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
95
- amount: { type: ScalarTypeEnum2.Float_unsecure(), isOptional: false },
96
- currency: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
97
- validUntil: { type: ScalarTypeEnum2.DateTime(), isOptional: true },
98
- orgId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
99
- ownerId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false }
86
+ dueDate: { type: ScalarTypeEnum2.DateTime(), isOptional: true },
87
+ issuedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: true },
88
+ paidAt: { type: ScalarTypeEnum2.DateTime(), isOptional: true }
100
89
  }
101
90
  });
102
- var AcceptQuoteInputModel = defineSchemaModel2({
103
- name: "AcceptQuoteInput",
104
- description: "Input for accepting a quote",
91
+ var IssueInvoiceInputModel = defineSchemaModel2({
92
+ name: "IssueInvoiceInput",
93
+ description: "Input for issuing an invoice",
105
94
  fields: {
106
- quoteId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
107
- acceptedBy: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
108
- notes: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true }
95
+ jobId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
96
+ dueDate: { type: ScalarTypeEnum2.DateTime(), isOptional: true },
97
+ notes: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
98
+ lineItems: { type: ScalarTypeEnum2.JSON(), isOptional: true }
109
99
  }
110
100
  });
111
101
 
112
- // src/quote/quote.operations.ts
102
+ // src/invoice/invoice.operations.ts
113
103
  import { defineCommand as defineCommand2 } from "@contractspec/lib.contracts-spec";
114
104
  var OWNERS2 = ["@examples.service-business-os"];
115
- var CreateQuoteContract = defineCommand2({
105
+ var IssueInvoiceContract = defineCommand2({
116
106
  meta: {
117
- key: "service.quote.create",
107
+ key: "service.invoice.issue",
118
108
  version: "1.0.0",
119
109
  stability: "stable",
120
110
  owners: [...OWNERS2],
121
- tags: ["service-business-os", "quote", "create"],
122
- description: "Create a quote/proposal.",
123
- goal: "Quote clients.",
124
- context: "Quote creation."
111
+ tags: ["service-business-os", "invoice", "issue"],
112
+ description: "Issue an invoice for a job.",
113
+ goal: "Bill clients.",
114
+ context: "Billing."
125
115
  },
126
116
  io: {
127
- input: CreateQuoteInputModel,
128
- output: QuoteModel
117
+ input: IssueInvoiceInputModel,
118
+ output: InvoiceModel
129
119
  },
130
120
  policy: { auth: "user" },
131
121
  acceptance: {
132
122
  scenarios: [
133
123
  {
134
- key: "create-quote-happy-path",
135
- given: ["Client exists"],
136
- when: ["User creates quote"],
137
- then: ["Quote is created"]
124
+ key: "issue-invoice-happy-path",
125
+ given: ["Job is complete"],
126
+ when: ["User issues invoice"],
127
+ then: ["Invoice is created and sent"]
138
128
  }
139
129
  ],
140
130
  examples: [
141
131
  {
142
- key: "create-proposal",
132
+ key: "issue-standard",
143
133
  input: {
144
- clientId: "client-123",
145
- items: [{ description: "Project A", price: 5000 }]
134
+ jobId: "job-123",
135
+ dueDate: "2025-02-01",
136
+ items: [{ description: "Service", amount: 100 }]
146
137
  },
147
- output: { id: "quote-123", status: "draft", total: 5000 }
148
- }
149
- ]
150
- }
151
- });
152
- var AcceptQuoteContract = defineCommand2({
153
- meta: {
154
- key: "service.quote.accept",
155
- version: "1.0.0",
156
- stability: "stable",
157
- owners: [...OWNERS2],
158
- tags: ["service-business-os", "quote", "accept"],
159
- description: "Accept a quote.",
160
- goal: "Confirm quote.",
161
- context: "Quote acceptance."
162
- },
163
- io: {
164
- input: AcceptQuoteInputModel,
165
- output: QuoteModel
166
- },
167
- policy: { auth: "user" },
168
- acceptance: {
169
- scenarios: [
170
- {
171
- key: "accept-quote-happy-path",
172
- given: ["Quote is open"],
173
- when: ["Client accepts quote"],
174
- then: ["Quote status becomes ACCEPTED"]
175
- }
176
- ],
177
- examples: [
178
- {
179
- key: "client-accepts",
180
- input: { quoteId: "quote-123", signature: "John Doe" },
181
- output: { id: "quote-123", status: "accepted" }
138
+ output: { id: "inv-456", status: "issued", total: 100 }
182
139
  }
183
140
  ]
184
141
  }
@@ -348,114 +305,42 @@ var CompleteJobContract = defineCommand3({
348
305
  ]
349
306
  }
350
307
  });
351
- // src/invoice/invoice.schema.ts
308
+ // src/payment/payment.schema.ts
352
309
  import { defineSchemaModel as defineSchemaModel5, ScalarTypeEnum as ScalarTypeEnum5 } from "@contractspec/lib.schema";
353
- var InvoiceModel = defineSchemaModel5({
354
- name: "Invoice",
355
- description: "Invoice issued for a job",
310
+ var PaymentModel = defineSchemaModel5({
311
+ name: "Payment",
312
+ description: "Payment applied to invoice",
356
313
  fields: {
357
314
  id: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
358
- jobId: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
359
- invoiceNumber: {
360
- type: ScalarTypeEnum5.String_unsecure(),
361
- isOptional: false
362
- },
315
+ invoiceId: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
363
316
  amount: { type: ScalarTypeEnum5.Float_unsecure(), isOptional: false },
364
317
  currency: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
365
- status: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
366
- dueDate: { type: ScalarTypeEnum5.DateTime(), isOptional: true },
367
- issuedAt: { type: ScalarTypeEnum5.DateTime(), isOptional: true },
368
- paidAt: { type: ScalarTypeEnum5.DateTime(), isOptional: true }
369
- }
370
- });
371
- var IssueInvoiceInputModel = defineSchemaModel5({
372
- name: "IssueInvoiceInput",
373
- description: "Input for issuing an invoice",
374
- fields: {
375
- jobId: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
376
- dueDate: { type: ScalarTypeEnum5.DateTime(), isOptional: true },
377
- notes: { type: ScalarTypeEnum5.String_unsecure(), isOptional: true },
378
- lineItems: { type: ScalarTypeEnum5.JSON(), isOptional: true }
379
- }
380
- });
381
-
382
- // src/invoice/invoice.operations.ts
383
- import { defineCommand as defineCommand4 } from "@contractspec/lib.contracts-spec";
384
- var OWNERS4 = ["@examples.service-business-os"];
385
- var IssueInvoiceContract = defineCommand4({
386
- meta: {
387
- key: "service.invoice.issue",
388
- version: "1.0.0",
389
- stability: "stable",
390
- owners: [...OWNERS4],
391
- tags: ["service-business-os", "invoice", "issue"],
392
- description: "Issue an invoice for a job.",
393
- goal: "Bill clients.",
394
- context: "Billing."
395
- },
396
- io: {
397
- input: IssueInvoiceInputModel,
398
- output: InvoiceModel
399
- },
400
- policy: { auth: "user" },
401
- acceptance: {
402
- scenarios: [
403
- {
404
- key: "issue-invoice-happy-path",
405
- given: ["Job is complete"],
406
- when: ["User issues invoice"],
407
- then: ["Invoice is created and sent"]
408
- }
409
- ],
410
- examples: [
411
- {
412
- key: "issue-standard",
413
- input: {
414
- jobId: "job-123",
415
- dueDate: "2025-02-01",
416
- items: [{ description: "Service", amount: 100 }]
417
- },
418
- output: { id: "inv-456", status: "issued", total: 100 }
419
- }
420
- ]
421
- }
422
- });
423
- // src/payment/payment.schema.ts
424
- import { defineSchemaModel as defineSchemaModel6, ScalarTypeEnum as ScalarTypeEnum6 } from "@contractspec/lib.schema";
425
- var PaymentModel = defineSchemaModel6({
426
- name: "Payment",
427
- description: "Payment applied to invoice",
428
- fields: {
429
- id: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
430
- invoiceId: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
431
- amount: { type: ScalarTypeEnum6.Float_unsecure(), isOptional: false },
432
- currency: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
433
- method: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
434
- reference: { type: ScalarTypeEnum6.String_unsecure(), isOptional: true },
435
- receivedAt: { type: ScalarTypeEnum6.DateTime(), isOptional: false }
318
+ method: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
319
+ reference: { type: ScalarTypeEnum5.String_unsecure(), isOptional: true },
320
+ receivedAt: { type: ScalarTypeEnum5.DateTime(), isOptional: false }
436
321
  }
437
322
  });
438
- var RecordPaymentInputModel = defineSchemaModel6({
323
+ var RecordPaymentInputModel = defineSchemaModel5({
439
324
  name: "RecordPaymentInput",
440
325
  description: "Input for recording a payment",
441
326
  fields: {
442
- invoiceId: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
443
- amount: { type: ScalarTypeEnum6.Float_unsecure(), isOptional: false },
444
- method: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
445
- reference: { type: ScalarTypeEnum6.String_unsecure(), isOptional: true },
446
- receivedAt: { type: ScalarTypeEnum6.DateTime(), isOptional: true }
327
+ invoiceId: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
328
+ amount: { type: ScalarTypeEnum5.Float_unsecure(), isOptional: false },
329
+ method: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
330
+ reference: { type: ScalarTypeEnum5.String_unsecure(), isOptional: true },
331
+ receivedAt: { type: ScalarTypeEnum5.DateTime(), isOptional: true }
447
332
  }
448
333
  });
449
334
 
450
335
  // src/payment/payment.operations.ts
451
- import { defineCommand as defineCommand5 } from "@contractspec/lib.contracts-spec";
452
- var OWNERS5 = ["@examples.service-business-os"];
453
- var RecordPaymentContract = defineCommand5({
336
+ import { defineCommand as defineCommand4 } from "@contractspec/lib.contracts-spec";
337
+ var OWNERS4 = ["@examples.service-business-os"];
338
+ var RecordPaymentContract = defineCommand4({
454
339
  meta: {
455
340
  key: "service.payment.record",
456
341
  version: "1.0.0",
457
342
  stability: "stable",
458
- owners: [...OWNERS5],
343
+ owners: [...OWNERS4],
459
344
  tags: ["service-business-os", "payment", "record"],
460
345
  description: "Record a payment.",
461
346
  goal: "Track payments.",
@@ -651,6 +536,121 @@ var PaymentListPresentation = definePresentation({
651
536
  }
652
537
  });
653
538
 
539
+ // src/quote/quote.schema.ts
540
+ import { defineSchemaModel as defineSchemaModel6, ScalarTypeEnum as ScalarTypeEnum6 } from "@contractspec/lib.schema";
541
+ var QuoteModel = defineSchemaModel6({
542
+ name: "Quote",
543
+ description: "Quote/proposal",
544
+ fields: {
545
+ id: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
546
+ clientId: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
547
+ title: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
548
+ description: { type: ScalarTypeEnum6.String_unsecure(), isOptional: true },
549
+ amount: { type: ScalarTypeEnum6.Float_unsecure(), isOptional: false },
550
+ currency: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
551
+ status: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
552
+ validUntil: { type: ScalarTypeEnum6.DateTime(), isOptional: true },
553
+ createdAt: { type: ScalarTypeEnum6.DateTime(), isOptional: false }
554
+ }
555
+ });
556
+ var CreateQuoteInputModel = defineSchemaModel6({
557
+ name: "CreateQuoteInput",
558
+ description: "Input for creating a quote",
559
+ fields: {
560
+ clientId: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
561
+ title: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
562
+ description: { type: ScalarTypeEnum6.String_unsecure(), isOptional: true },
563
+ amount: { type: ScalarTypeEnum6.Float_unsecure(), isOptional: false },
564
+ currency: { type: ScalarTypeEnum6.String_unsecure(), isOptional: true },
565
+ validUntil: { type: ScalarTypeEnum6.DateTime(), isOptional: true },
566
+ orgId: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
567
+ ownerId: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false }
568
+ }
569
+ });
570
+ var AcceptQuoteInputModel = defineSchemaModel6({
571
+ name: "AcceptQuoteInput",
572
+ description: "Input for accepting a quote",
573
+ fields: {
574
+ quoteId: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
575
+ acceptedBy: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
576
+ notes: { type: ScalarTypeEnum6.String_unsecure(), isOptional: true }
577
+ }
578
+ });
579
+
580
+ // src/quote/quote.operations.ts
581
+ import { defineCommand as defineCommand5 } from "@contractspec/lib.contracts-spec";
582
+ var OWNERS5 = ["@examples.service-business-os"];
583
+ var CreateQuoteContract = defineCommand5({
584
+ meta: {
585
+ key: "service.quote.create",
586
+ version: "1.0.0",
587
+ stability: "stable",
588
+ owners: [...OWNERS5],
589
+ tags: ["service-business-os", "quote", "create"],
590
+ description: "Create a quote/proposal.",
591
+ goal: "Quote clients.",
592
+ context: "Quote creation."
593
+ },
594
+ io: {
595
+ input: CreateQuoteInputModel,
596
+ output: QuoteModel
597
+ },
598
+ policy: { auth: "user" },
599
+ acceptance: {
600
+ scenarios: [
601
+ {
602
+ key: "create-quote-happy-path",
603
+ given: ["Client exists"],
604
+ when: ["User creates quote"],
605
+ then: ["Quote is created"]
606
+ }
607
+ ],
608
+ examples: [
609
+ {
610
+ key: "create-proposal",
611
+ input: {
612
+ clientId: "client-123",
613
+ items: [{ description: "Project A", price: 5000 }]
614
+ },
615
+ output: { id: "quote-123", status: "draft", total: 5000 }
616
+ }
617
+ ]
618
+ }
619
+ });
620
+ var AcceptQuoteContract = defineCommand5({
621
+ meta: {
622
+ key: "service.quote.accept",
623
+ version: "1.0.0",
624
+ stability: "stable",
625
+ owners: [...OWNERS5],
626
+ tags: ["service-business-os", "quote", "accept"],
627
+ description: "Accept a quote.",
628
+ goal: "Confirm quote.",
629
+ context: "Quote acceptance."
630
+ },
631
+ io: {
632
+ input: AcceptQuoteInputModel,
633
+ output: QuoteModel
634
+ },
635
+ policy: { auth: "user" },
636
+ acceptance: {
637
+ scenarios: [
638
+ {
639
+ key: "accept-quote-happy-path",
640
+ given: ["Quote is open"],
641
+ when: ["Client accepts quote"],
642
+ then: ["Quote status becomes ACCEPTED"]
643
+ }
644
+ ],
645
+ examples: [
646
+ {
647
+ key: "client-accepts",
648
+ input: { quoteId: "quote-123", signature: "John Doe" },
649
+ output: { id: "quote-123", status: "accepted" }
650
+ }
651
+ ]
652
+ }
653
+ });
654
654
  // src/service.feature.ts
655
655
  import { defineFeature } from "@contractspec/lib.contracts-spec";
656
656
  var ServiceBusinessFeature = defineFeature({
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * Invoice domain - Invoice management.
3
3
  */
4
- export { InvoiceModel, IssueInvoiceInputModel } from './invoice.schema';
5
4
  export { IssueInvoiceContract } from './invoice.operations';
5
+ export { InvoiceModel, IssueInvoiceInputModel } from './invoice.schema';
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * Job domain - Job scheduling and management.
3
3
  */
4
- export { JobModel, ScheduleJobInputModel, CompleteJobInputModel, } from './job.schema';
5
- export { ScheduleJobContract, CompleteJobContract, ListJobsOperation, ListJobsInputModel, ListJobsOutputModel, } from './job.operations';
4
+ export { CompleteJobContract, ListJobsInputModel, ListJobsOperation, ListJobsOutputModel, ScheduleJobContract, } from './job.operations';
5
+ export { CompleteJobInputModel, JobModel, ScheduleJobInputModel, } from './job.schema';
@@ -1,6 +1,6 @@
1
1
  // src/events.ts
2
- import { ScalarTypeEnum, defineSchemaModel } from "@contractspec/lib.schema";
3
2
  import { defineEvent } from "@contractspec/lib.contracts-spec";
3
+ import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
4
4
  var QuoteEventPayload = defineSchemaModel({
5
5
  name: "QuoteEventPayload",
6
6
  description: "Event payload for quote lifecycle",