@contractspec/example.service-business-os 3.7.17 → 3.7.18
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/browser/client/client.operations.js +1 -72
- package/dist/browser/client/client.schema.js +1 -31
- package/dist/browser/client/index.js +1 -74
- package/dist/browser/docs/index.js +5 -49
- package/dist/browser/docs/service-business-os.docblock.js +5 -49
- package/dist/browser/entities/index.js +1 -246
- package/dist/browser/events.js +1 -135
- package/dist/browser/example.js +1 -39
- package/dist/browser/handlers/index.js +1 -5
- package/dist/browser/index.js +1 -766
- package/dist/browser/invoice/index.js +1 -77
- package/dist/browser/invoice/invoice.operations.js +1 -75
- package/dist/browser/invoice/invoice.schema.js +1 -34
- package/dist/browser/job/index.js +1 -175
- package/dist/browser/job/job.operations.js +1 -172
- package/dist/browser/job/job.schema.js +1 -41
- package/dist/browser/operations/index.js +1 -506
- package/dist/browser/payment/index.js +1 -69
- package/dist/browser/payment/payment.operations.js +1 -67
- package/dist/browser/payment/payment.schema.js +1 -30
- package/dist/browser/presentations/index.js +1 -13
- package/dist/browser/presentations.js +1 -175
- package/dist/browser/quote/index.js +1 -122
- package/dist/browser/quote/quote.operations.js +1 -119
- package/dist/browser/quote/quote.schema.js +1 -45
- package/dist/browser/service-business-os.capability.js +1 -31
- package/dist/browser/service.feature.js +1 -85
- package/dist/client/client.operations.js +1 -72
- package/dist/client/client.schema.js +1 -31
- package/dist/client/index.js +1 -74
- package/dist/docs/index.js +5 -49
- package/dist/docs/service-business-os.docblock.js +5 -49
- package/dist/entities/index.js +1 -246
- package/dist/events.js +1 -135
- package/dist/example.js +1 -39
- package/dist/handlers/index.js +1 -5
- package/dist/index.js +1 -766
- package/dist/invoice/index.js +1 -77
- package/dist/invoice/invoice.operations.js +1 -75
- package/dist/invoice/invoice.schema.js +1 -34
- package/dist/job/index.js +1 -175
- package/dist/job/job.operations.js +1 -172
- package/dist/job/job.schema.js +1 -41
- package/dist/node/client/client.operations.js +1 -72
- package/dist/node/client/client.schema.js +1 -31
- package/dist/node/client/index.js +1 -74
- package/dist/node/docs/index.js +5 -49
- package/dist/node/docs/service-business-os.docblock.js +5 -49
- package/dist/node/entities/index.js +1 -246
- package/dist/node/events.js +1 -135
- package/dist/node/example.js +1 -39
- package/dist/node/handlers/index.js +1 -5
- package/dist/node/index.js +1 -766
- package/dist/node/invoice/index.js +1 -77
- package/dist/node/invoice/invoice.operations.js +1 -75
- package/dist/node/invoice/invoice.schema.js +1 -34
- package/dist/node/job/index.js +1 -175
- package/dist/node/job/job.operations.js +1 -172
- package/dist/node/job/job.schema.js +1 -41
- package/dist/node/operations/index.js +1 -506
- package/dist/node/payment/index.js +1 -69
- package/dist/node/payment/payment.operations.js +1 -67
- package/dist/node/payment/payment.schema.js +1 -30
- package/dist/node/presentations/index.js +1 -13
- package/dist/node/presentations.js +1 -175
- package/dist/node/quote/index.js +1 -122
- package/dist/node/quote/quote.operations.js +1 -119
- package/dist/node/quote/quote.schema.js +1 -45
- package/dist/node/service-business-os.capability.js +1 -31
- package/dist/node/service.feature.js +1 -85
- package/dist/operations/index.js +1 -506
- package/dist/payment/index.js +1 -69
- package/dist/payment/payment.operations.js +1 -67
- package/dist/payment/payment.schema.js +1 -30
- package/dist/presentations/index.js +1 -13
- package/dist/presentations.js +1 -175
- package/dist/quote/index.js +1 -122
- package/dist/quote/quote.operations.js +1 -119
- package/dist/quote/quote.schema.js +1 -45
- package/dist/service-business-os.capability.js +1 -31
- package/dist/service.feature.js +1 -85
- package/package.json +5 -5
package/dist/operations/index.js
CHANGED
|
@@ -1,507 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
// src/client/client.schema.ts
|
|
3
|
-
import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
|
|
4
|
-
var ClientModel = defineSchemaModel({
|
|
5
|
-
name: "Client",
|
|
6
|
-
description: "Client profile",
|
|
7
|
-
fields: {
|
|
8
|
-
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
9
|
-
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
10
|
-
contactEmail: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
11
|
-
phone: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
12
|
-
orgId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
13
|
-
ownerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
14
|
-
createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
var CreateClientInputModel = defineSchemaModel({
|
|
18
|
-
name: "CreateClientInput",
|
|
19
|
-
description: "Input for creating a client",
|
|
20
|
-
fields: {
|
|
21
|
-
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
22
|
-
contactEmail: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
23
|
-
phone: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
24
|
-
orgId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
25
|
-
ownerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
26
|
-
metadata: { type: ScalarTypeEnum.JSON(), isOptional: true }
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
// src/client/client.operations.ts
|
|
31
|
-
import { defineCommand } from "@contractspec/lib.contracts-spec";
|
|
32
|
-
var OWNERS = ["@examples.service-business-os"];
|
|
33
|
-
var CreateClientContract = defineCommand({
|
|
34
|
-
meta: {
|
|
35
|
-
key: "service.client.create",
|
|
36
|
-
version: "1.0.0",
|
|
37
|
-
stability: "stable",
|
|
38
|
-
owners: [...OWNERS],
|
|
39
|
-
tags: ["service-business-os", "client", "create"],
|
|
40
|
-
description: "Create a new client.",
|
|
41
|
-
goal: "Onboard clients.",
|
|
42
|
-
context: "CRM."
|
|
43
|
-
},
|
|
44
|
-
io: {
|
|
45
|
-
input: CreateClientInputModel,
|
|
46
|
-
output: ClientModel
|
|
47
|
-
},
|
|
48
|
-
policy: { auth: "user" },
|
|
49
|
-
acceptance: {
|
|
50
|
-
scenarios: [
|
|
51
|
-
{
|
|
52
|
-
key: "create-client-happy-path",
|
|
53
|
-
given: ["User is authenticated"],
|
|
54
|
-
when: ["User creates a new client"],
|
|
55
|
-
then: ["Client is created"]
|
|
56
|
-
}
|
|
57
|
-
],
|
|
58
|
-
examples: [
|
|
59
|
-
{
|
|
60
|
-
key: "create-basic",
|
|
61
|
-
input: {
|
|
62
|
-
name: "Acme Corp",
|
|
63
|
-
email: "contact@acme.com",
|
|
64
|
-
phone: "555-0123"
|
|
65
|
-
},
|
|
66
|
-
output: { id: "client-123", name: "Acme Corp" }
|
|
67
|
-
}
|
|
68
|
-
]
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
// src/invoice/invoice.schema.ts
|
|
72
|
-
import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
|
|
73
|
-
var InvoiceModel = defineSchemaModel2({
|
|
74
|
-
name: "Invoice",
|
|
75
|
-
description: "Invoice issued for a job",
|
|
76
|
-
fields: {
|
|
77
|
-
id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
78
|
-
jobId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
79
|
-
invoiceNumber: {
|
|
80
|
-
type: ScalarTypeEnum2.String_unsecure(),
|
|
81
|
-
isOptional: false
|
|
82
|
-
},
|
|
83
|
-
amount: { type: ScalarTypeEnum2.Float_unsecure(), isOptional: false },
|
|
84
|
-
currency: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
85
|
-
status: { 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 }
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
var IssueInvoiceInputModel = defineSchemaModel2({
|
|
92
|
-
name: "IssueInvoiceInput",
|
|
93
|
-
description: "Input for issuing an invoice",
|
|
94
|
-
fields: {
|
|
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 }
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
// src/invoice/invoice.operations.ts
|
|
103
|
-
import { defineCommand as defineCommand2 } from "@contractspec/lib.contracts-spec";
|
|
104
|
-
var OWNERS2 = ["@examples.service-business-os"];
|
|
105
|
-
var IssueInvoiceContract = defineCommand2({
|
|
106
|
-
meta: {
|
|
107
|
-
key: "service.invoice.issue",
|
|
108
|
-
version: "1.0.0",
|
|
109
|
-
stability: "stable",
|
|
110
|
-
owners: [...OWNERS2],
|
|
111
|
-
tags: ["service-business-os", "invoice", "issue"],
|
|
112
|
-
description: "Issue an invoice for a job.",
|
|
113
|
-
goal: "Bill clients.",
|
|
114
|
-
context: "Billing."
|
|
115
|
-
},
|
|
116
|
-
io: {
|
|
117
|
-
input: IssueInvoiceInputModel,
|
|
118
|
-
output: InvoiceModel
|
|
119
|
-
},
|
|
120
|
-
policy: { auth: "user" },
|
|
121
|
-
acceptance: {
|
|
122
|
-
scenarios: [
|
|
123
|
-
{
|
|
124
|
-
key: "issue-invoice-happy-path",
|
|
125
|
-
given: ["Job is complete"],
|
|
126
|
-
when: ["User issues invoice"],
|
|
127
|
-
then: ["Invoice is created and sent"]
|
|
128
|
-
}
|
|
129
|
-
],
|
|
130
|
-
examples: [
|
|
131
|
-
{
|
|
132
|
-
key: "issue-standard",
|
|
133
|
-
input: {
|
|
134
|
-
jobId: "job-123",
|
|
135
|
-
dueDate: "2025-02-01",
|
|
136
|
-
items: [{ description: "Service", amount: 100 }]
|
|
137
|
-
},
|
|
138
|
-
output: { id: "inv-456", status: "issued", total: 100 }
|
|
139
|
-
}
|
|
140
|
-
]
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
// src/job/job.schema.ts
|
|
144
|
-
import { defineSchemaModel as defineSchemaModel3, ScalarTypeEnum as ScalarTypeEnum3 } from "@contractspec/lib.schema";
|
|
145
|
-
var JobModel = defineSchemaModel3({
|
|
146
|
-
name: "Job",
|
|
147
|
-
description: "Scheduled job",
|
|
148
|
-
fields: {
|
|
149
|
-
id: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
150
|
-
quoteId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
151
|
-
clientId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
152
|
-
title: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
153
|
-
status: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
154
|
-
scheduledAt: { type: ScalarTypeEnum3.DateTime(), isOptional: true },
|
|
155
|
-
completedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: true },
|
|
156
|
-
assignedTo: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true }
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
var ScheduleJobInputModel = defineSchemaModel3({
|
|
160
|
-
name: "ScheduleJobInput",
|
|
161
|
-
description: "Input for scheduling a job",
|
|
162
|
-
fields: {
|
|
163
|
-
quoteId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
164
|
-
scheduledAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false },
|
|
165
|
-
assignedTo: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
|
|
166
|
-
location: { type: ScalarTypeEnum3.JSON(), isOptional: true },
|
|
167
|
-
title: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true }
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
var CompleteJobInputModel = defineSchemaModel3({
|
|
171
|
-
name: "CompleteJobInput",
|
|
172
|
-
description: "Input for completing a job",
|
|
173
|
-
fields: {
|
|
174
|
-
jobId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
175
|
-
completedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: true },
|
|
176
|
-
notes: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true }
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
// src/job/job.operations.ts
|
|
181
|
-
import { defineCommand as defineCommand3, defineQuery } from "@contractspec/lib.contracts-spec";
|
|
182
|
-
import { defineSchemaModel as defineSchemaModel4, ScalarTypeEnum as ScalarTypeEnum4 } from "@contractspec/lib.schema";
|
|
183
|
-
var OWNERS3 = ["@examples.service-business-os"];
|
|
184
|
-
var ListJobsInputModel = defineSchemaModel4({
|
|
185
|
-
name: "ListJobsInput",
|
|
186
|
-
description: "Input for listing jobs",
|
|
187
|
-
fields: {
|
|
188
|
-
status: { type: ScalarTypeEnum4.String_unsecure(), isOptional: true },
|
|
189
|
-
clientId: { type: ScalarTypeEnum4.String_unsecure(), isOptional: true },
|
|
190
|
-
limit: { type: ScalarTypeEnum4.Int_unsecure(), isOptional: true },
|
|
191
|
-
offset: { type: ScalarTypeEnum4.Int_unsecure(), isOptional: true }
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
var ListJobsOutputModel = defineSchemaModel4({
|
|
195
|
-
name: "ListJobsOutput",
|
|
196
|
-
description: "Output for listing jobs",
|
|
197
|
-
fields: {
|
|
198
|
-
jobs: { type: JobModel, isOptional: false, isList: true },
|
|
199
|
-
total: { type: ScalarTypeEnum4.Int_unsecure(), isOptional: false }
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
var ListJobsOperation = defineQuery({
|
|
203
|
-
meta: {
|
|
204
|
-
key: "service.job.list",
|
|
205
|
-
version: "1.0.0",
|
|
206
|
-
stability: "stable",
|
|
207
|
-
owners: [...OWNERS3],
|
|
208
|
-
tags: ["service-business-os", "job", "list", "query"],
|
|
209
|
-
description: "List all jobs with filtering",
|
|
210
|
-
goal: "Retrieve list of jobs",
|
|
211
|
-
context: "Job management"
|
|
212
|
-
},
|
|
213
|
-
io: {
|
|
214
|
-
input: ListJobsInputModel,
|
|
215
|
-
output: ListJobsOutputModel
|
|
216
|
-
},
|
|
217
|
-
policy: { auth: "user" },
|
|
218
|
-
acceptance: {
|
|
219
|
-
scenarios: [
|
|
220
|
-
{
|
|
221
|
-
key: "list-jobs-happy-path",
|
|
222
|
-
given: ["Jobs exist"],
|
|
223
|
-
when: ["User lists jobs"],
|
|
224
|
-
then: ["List of jobs is returned"]
|
|
225
|
-
}
|
|
226
|
-
],
|
|
227
|
-
examples: [
|
|
228
|
-
{
|
|
229
|
-
key: "list-active",
|
|
230
|
-
input: { status: "scheduled", limit: 10 },
|
|
231
|
-
output: { jobs: [], total: 5 }
|
|
232
|
-
}
|
|
233
|
-
]
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
var ScheduleJobContract = defineCommand3({
|
|
237
|
-
meta: {
|
|
238
|
-
key: "service.job.schedule",
|
|
239
|
-
version: "1.0.0",
|
|
240
|
-
stability: "stable",
|
|
241
|
-
owners: [...OWNERS3],
|
|
242
|
-
tags: ["service-business-os", "job", "schedule"],
|
|
243
|
-
description: "Schedule a job.",
|
|
244
|
-
goal: "Schedule work.",
|
|
245
|
-
context: "Job scheduling."
|
|
246
|
-
},
|
|
247
|
-
io: {
|
|
248
|
-
input: ScheduleJobInputModel,
|
|
249
|
-
output: JobModel
|
|
250
|
-
},
|
|
251
|
-
policy: { auth: "user" },
|
|
252
|
-
acceptance: {
|
|
253
|
-
scenarios: [
|
|
254
|
-
{
|
|
255
|
-
key: "schedule-job-happy-path",
|
|
256
|
-
given: ["Client exists"],
|
|
257
|
-
when: ["User schedules job"],
|
|
258
|
-
then: ["Job is created with status SCHEDULED"]
|
|
259
|
-
}
|
|
260
|
-
],
|
|
261
|
-
examples: [
|
|
262
|
-
{
|
|
263
|
-
key: "schedule-repair",
|
|
264
|
-
input: {
|
|
265
|
-
clientId: "client-123",
|
|
266
|
-
date: "2025-01-20T10:00:00Z",
|
|
267
|
-
type: "repair"
|
|
268
|
-
},
|
|
269
|
-
output: { id: "job-456", status: "scheduled" }
|
|
270
|
-
}
|
|
271
|
-
]
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
|
-
var CompleteJobContract = defineCommand3({
|
|
275
|
-
meta: {
|
|
276
|
-
key: "service.job.complete",
|
|
277
|
-
version: "1.0.0",
|
|
278
|
-
stability: "stable",
|
|
279
|
-
owners: [...OWNERS3],
|
|
280
|
-
tags: ["service-business-os", "job", "complete"],
|
|
281
|
-
description: "Mark a job as complete.",
|
|
282
|
-
goal: "Record job completion.",
|
|
283
|
-
context: "Job management."
|
|
284
|
-
},
|
|
285
|
-
io: {
|
|
286
|
-
input: CompleteJobInputModel,
|
|
287
|
-
output: JobModel
|
|
288
|
-
},
|
|
289
|
-
policy: { auth: "user" },
|
|
290
|
-
acceptance: {
|
|
291
|
-
scenarios: [
|
|
292
|
-
{
|
|
293
|
-
key: "complete-job-happy-path",
|
|
294
|
-
given: ["Job is scheduled"],
|
|
295
|
-
when: ["User completes job"],
|
|
296
|
-
then: ["Job status becomes COMPLETED"]
|
|
297
|
-
}
|
|
298
|
-
],
|
|
299
|
-
examples: [
|
|
300
|
-
{
|
|
301
|
-
key: "mark-complete",
|
|
302
|
-
input: { jobId: "job-456", notes: "Done successfully" },
|
|
303
|
-
output: { id: "job-456", status: "completed" }
|
|
304
|
-
}
|
|
305
|
-
]
|
|
306
|
-
}
|
|
307
|
-
});
|
|
308
|
-
// src/payment/payment.schema.ts
|
|
309
|
-
import { defineSchemaModel as defineSchemaModel5, ScalarTypeEnum as ScalarTypeEnum5 } from "@contractspec/lib.schema";
|
|
310
|
-
var PaymentModel = defineSchemaModel5({
|
|
311
|
-
name: "Payment",
|
|
312
|
-
description: "Payment applied to invoice",
|
|
313
|
-
fields: {
|
|
314
|
-
id: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
|
|
315
|
-
invoiceId: { type: ScalarTypeEnum5.String_unsecure(), isOptional: false },
|
|
316
|
-
amount: { type: ScalarTypeEnum5.Float_unsecure(), isOptional: false },
|
|
317
|
-
currency: { type: ScalarTypeEnum5.String_unsecure(), 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 }
|
|
321
|
-
}
|
|
322
|
-
});
|
|
323
|
-
var RecordPaymentInputModel = defineSchemaModel5({
|
|
324
|
-
name: "RecordPaymentInput",
|
|
325
|
-
description: "Input for recording a payment",
|
|
326
|
-
fields: {
|
|
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 }
|
|
332
|
-
}
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
// src/payment/payment.operations.ts
|
|
336
|
-
import { defineCommand as defineCommand4 } from "@contractspec/lib.contracts-spec";
|
|
337
|
-
var OWNERS4 = ["@examples.service-business-os"];
|
|
338
|
-
var RecordPaymentContract = defineCommand4({
|
|
339
|
-
meta: {
|
|
340
|
-
key: "service.payment.record",
|
|
341
|
-
version: "1.0.0",
|
|
342
|
-
stability: "stable",
|
|
343
|
-
owners: [...OWNERS4],
|
|
344
|
-
tags: ["service-business-os", "payment", "record"],
|
|
345
|
-
description: "Record a payment.",
|
|
346
|
-
goal: "Track payments.",
|
|
347
|
-
context: "Billing."
|
|
348
|
-
},
|
|
349
|
-
io: {
|
|
350
|
-
input: RecordPaymentInputModel,
|
|
351
|
-
output: PaymentModel
|
|
352
|
-
},
|
|
353
|
-
policy: { auth: "user" },
|
|
354
|
-
acceptance: {
|
|
355
|
-
scenarios: [
|
|
356
|
-
{
|
|
357
|
-
key: "record-payment-happy-path",
|
|
358
|
-
given: ["Invoice exists"],
|
|
359
|
-
when: ["User records payment"],
|
|
360
|
-
then: ["Payment is recorded"]
|
|
361
|
-
}
|
|
362
|
-
],
|
|
363
|
-
examples: [
|
|
364
|
-
{
|
|
365
|
-
key: "record-check",
|
|
366
|
-
input: { invoiceId: "inv-456", amount: 100, method: "check" },
|
|
367
|
-
output: { id: "pay-123", status: "completed" }
|
|
368
|
-
}
|
|
369
|
-
]
|
|
370
|
-
}
|
|
371
|
-
});
|
|
372
|
-
// src/quote/quote.schema.ts
|
|
373
|
-
import { defineSchemaModel as defineSchemaModel6, ScalarTypeEnum as ScalarTypeEnum6 } from "@contractspec/lib.schema";
|
|
374
|
-
var QuoteModel = defineSchemaModel6({
|
|
375
|
-
name: "Quote",
|
|
376
|
-
description: "Quote/proposal",
|
|
377
|
-
fields: {
|
|
378
|
-
id: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
|
|
379
|
-
clientId: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
|
|
380
|
-
title: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
|
|
381
|
-
description: { type: ScalarTypeEnum6.String_unsecure(), isOptional: true },
|
|
382
|
-
amount: { type: ScalarTypeEnum6.Float_unsecure(), isOptional: false },
|
|
383
|
-
currency: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
|
|
384
|
-
status: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
|
|
385
|
-
validUntil: { type: ScalarTypeEnum6.DateTime(), isOptional: true },
|
|
386
|
-
createdAt: { type: ScalarTypeEnum6.DateTime(), isOptional: false }
|
|
387
|
-
}
|
|
388
|
-
});
|
|
389
|
-
var CreateQuoteInputModel = defineSchemaModel6({
|
|
390
|
-
name: "CreateQuoteInput",
|
|
391
|
-
description: "Input for creating a quote",
|
|
392
|
-
fields: {
|
|
393
|
-
clientId: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
|
|
394
|
-
title: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
|
|
395
|
-
description: { type: ScalarTypeEnum6.String_unsecure(), isOptional: true },
|
|
396
|
-
amount: { type: ScalarTypeEnum6.Float_unsecure(), isOptional: false },
|
|
397
|
-
currency: { type: ScalarTypeEnum6.String_unsecure(), isOptional: true },
|
|
398
|
-
validUntil: { type: ScalarTypeEnum6.DateTime(), isOptional: true },
|
|
399
|
-
orgId: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
|
|
400
|
-
ownerId: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false }
|
|
401
|
-
}
|
|
402
|
-
});
|
|
403
|
-
var AcceptQuoteInputModel = defineSchemaModel6({
|
|
404
|
-
name: "AcceptQuoteInput",
|
|
405
|
-
description: "Input for accepting a quote",
|
|
406
|
-
fields: {
|
|
407
|
-
quoteId: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
|
|
408
|
-
acceptedBy: { type: ScalarTypeEnum6.String_unsecure(), isOptional: false },
|
|
409
|
-
notes: { type: ScalarTypeEnum6.String_unsecure(), isOptional: true }
|
|
410
|
-
}
|
|
411
|
-
});
|
|
412
|
-
|
|
413
|
-
// src/quote/quote.operations.ts
|
|
414
|
-
import { defineCommand as defineCommand5 } from "@contractspec/lib.contracts-spec";
|
|
415
|
-
var OWNERS5 = ["@examples.service-business-os"];
|
|
416
|
-
var CreateQuoteContract = defineCommand5({
|
|
417
|
-
meta: {
|
|
418
|
-
key: "service.quote.create",
|
|
419
|
-
version: "1.0.0",
|
|
420
|
-
stability: "stable",
|
|
421
|
-
owners: [...OWNERS5],
|
|
422
|
-
tags: ["service-business-os", "quote", "create"],
|
|
423
|
-
description: "Create a quote/proposal.",
|
|
424
|
-
goal: "Quote clients.",
|
|
425
|
-
context: "Quote creation."
|
|
426
|
-
},
|
|
427
|
-
io: {
|
|
428
|
-
input: CreateQuoteInputModel,
|
|
429
|
-
output: QuoteModel
|
|
430
|
-
},
|
|
431
|
-
policy: { auth: "user" },
|
|
432
|
-
acceptance: {
|
|
433
|
-
scenarios: [
|
|
434
|
-
{
|
|
435
|
-
key: "create-quote-happy-path",
|
|
436
|
-
given: ["Client exists"],
|
|
437
|
-
when: ["User creates quote"],
|
|
438
|
-
then: ["Quote is created"]
|
|
439
|
-
}
|
|
440
|
-
],
|
|
441
|
-
examples: [
|
|
442
|
-
{
|
|
443
|
-
key: "create-proposal",
|
|
444
|
-
input: {
|
|
445
|
-
clientId: "client-123",
|
|
446
|
-
items: [{ description: "Project A", price: 5000 }]
|
|
447
|
-
},
|
|
448
|
-
output: { id: "quote-123", status: "draft", total: 5000 }
|
|
449
|
-
}
|
|
450
|
-
]
|
|
451
|
-
}
|
|
452
|
-
});
|
|
453
|
-
var AcceptQuoteContract = defineCommand5({
|
|
454
|
-
meta: {
|
|
455
|
-
key: "service.quote.accept",
|
|
456
|
-
version: "1.0.0",
|
|
457
|
-
stability: "stable",
|
|
458
|
-
owners: [...OWNERS5],
|
|
459
|
-
tags: ["service-business-os", "quote", "accept"],
|
|
460
|
-
description: "Accept a quote.",
|
|
461
|
-
goal: "Confirm quote.",
|
|
462
|
-
context: "Quote acceptance."
|
|
463
|
-
},
|
|
464
|
-
io: {
|
|
465
|
-
input: AcceptQuoteInputModel,
|
|
466
|
-
output: QuoteModel
|
|
467
|
-
},
|
|
468
|
-
policy: { auth: "user" },
|
|
469
|
-
acceptance: {
|
|
470
|
-
scenarios: [
|
|
471
|
-
{
|
|
472
|
-
key: "accept-quote-happy-path",
|
|
473
|
-
given: ["Quote is open"],
|
|
474
|
-
when: ["Client accepts quote"],
|
|
475
|
-
then: ["Quote status becomes ACCEPTED"]
|
|
476
|
-
}
|
|
477
|
-
],
|
|
478
|
-
examples: [
|
|
479
|
-
{
|
|
480
|
-
key: "client-accepts",
|
|
481
|
-
input: { quoteId: "quote-123", signature: "John Doe" },
|
|
482
|
-
output: { id: "quote-123", status: "accepted" }
|
|
483
|
-
}
|
|
484
|
-
]
|
|
485
|
-
}
|
|
486
|
-
});
|
|
487
|
-
export {
|
|
488
|
-
ScheduleJobInputModel,
|
|
489
|
-
ScheduleJobContract,
|
|
490
|
-
RecordPaymentInputModel,
|
|
491
|
-
RecordPaymentContract,
|
|
492
|
-
QuoteModel,
|
|
493
|
-
PaymentModel,
|
|
494
|
-
JobModel,
|
|
495
|
-
IssueInvoiceInputModel,
|
|
496
|
-
IssueInvoiceContract,
|
|
497
|
-
InvoiceModel,
|
|
498
|
-
CreateQuoteInputModel,
|
|
499
|
-
CreateQuoteContract,
|
|
500
|
-
CreateClientInputModel,
|
|
501
|
-
CreateClientContract,
|
|
502
|
-
CompleteJobInputModel,
|
|
503
|
-
CompleteJobContract,
|
|
504
|
-
ClientModel,
|
|
505
|
-
AcceptQuoteInputModel,
|
|
506
|
-
AcceptQuoteContract
|
|
507
|
-
};
|
|
2
|
+
import{defineSchemaModel as U,ScalarTypeEnum as C}from"@contractspec/lib.schema";var v=U({name:"Client",description:"Client profile",fields:{id:{type:C.String_unsecure(),isOptional:!1},name:{type:C.String_unsecure(),isOptional:!1},contactEmail:{type:C.String_unsecure(),isOptional:!0},phone:{type:C.String_unsecure(),isOptional:!0},orgId:{type:C.String_unsecure(),isOptional:!1},ownerId:{type:C.String_unsecure(),isOptional:!1},createdAt:{type:C.DateTime(),isOptional:!1}}}),A=U({name:"CreateClientInput",description:"Input for creating a client",fields:{name:{type:C.String_unsecure(),isOptional:!1},contactEmail:{type:C.String_unsecure(),isOptional:!0},phone:{type:C.String_unsecure(),isOptional:!0},orgId:{type:C.String_unsecure(),isOptional:!1},ownerId:{type:C.String_unsecure(),isOptional:!1},metadata:{type:C.JSON(),isOptional:!0}}});import{defineCommand as d}from"@contractspec/lib.contracts-spec";var h=["@examples.service-business-os"],V=d({meta:{key:"service.client.create",version:"1.0.0",stability:"stable",owners:[...h],tags:["service-business-os","client","create"],description:"Create a new client.",goal:"Onboard clients.",context:"CRM."},io:{input:A,output:v},policy:{auth:"user"},acceptance:{scenarios:[{key:"create-client-happy-path",given:["User is authenticated"],when:["User creates a new client"],then:["Client is created"]}],examples:[{key:"create-basic",input:{name:"Acme Corp",email:"contact@acme.com",phone:"555-0123"},output:{id:"client-123",name:"Acme Corp"}}]}});import{defineSchemaModel as X,ScalarTypeEnum as x}from"@contractspec/lib.schema";var g=X({name:"Invoice",description:"Invoice issued for a job",fields:{id:{type:x.String_unsecure(),isOptional:!1},jobId:{type:x.String_unsecure(),isOptional:!1},invoiceNumber:{type:x.String_unsecure(),isOptional:!1},amount:{type:x.Float_unsecure(),isOptional:!1},currency:{type:x.String_unsecure(),isOptional:!1},status:{type:x.String_unsecure(),isOptional:!1},dueDate:{type:x.DateTime(),isOptional:!0},issuedAt:{type:x.DateTime(),isOptional:!0},paidAt:{type:x.DateTime(),isOptional:!0}}}),k=X({name:"IssueInvoiceInput",description:"Input for issuing an invoice",fields:{jobId:{type:x.String_unsecure(),isOptional:!1},dueDate:{type:x.DateTime(),isOptional:!0},notes:{type:x.String_unsecure(),isOptional:!0},lineItems:{type:x.JSON(),isOptional:!0}}});import{defineCommand as i}from"@contractspec/lib.contracts-spec";var s=["@examples.service-business-os"],Y=i({meta:{key:"service.invoice.issue",version:"1.0.0",stability:"stable",owners:[...s],tags:["service-business-os","invoice","issue"],description:"Issue an invoice for a job.",goal:"Bill clients.",context:"Billing."},io:{input:k,output:g},policy:{auth:"user"},acceptance:{scenarios:[{key:"issue-invoice-happy-path",given:["Job is complete"],when:["User issues invoice"],then:["Invoice is created and sent"]}],examples:[{key:"issue-standard",input:{jobId:"job-123",dueDate:"2025-02-01",items:[{description:"Service",amount:100}]},output:{id:"inv-456",status:"issued",total:100}}]}});import{defineSchemaModel as G,ScalarTypeEnum as o}from"@contractspec/lib.schema";var J=G({name:"Job",description:"Scheduled job",fields:{id:{type:o.String_unsecure(),isOptional:!1},quoteId:{type:o.String_unsecure(),isOptional:!1},clientId:{type:o.String_unsecure(),isOptional:!1},title:{type:o.String_unsecure(),isOptional:!1},status:{type:o.String_unsecure(),isOptional:!1},scheduledAt:{type:o.DateTime(),isOptional:!0},completedAt:{type:o.DateTime(),isOptional:!0},assignedTo:{type:o.String_unsecure(),isOptional:!0}}}),w=G({name:"ScheduleJobInput",description:"Input for scheduling a job",fields:{quoteId:{type:o.String_unsecure(),isOptional:!1},scheduledAt:{type:o.DateTime(),isOptional:!1},assignedTo:{type:o.String_unsecure(),isOptional:!0},location:{type:o.JSON(),isOptional:!0},title:{type:o.String_unsecure(),isOptional:!0}}}),L=G({name:"CompleteJobInput",description:"Input for completing a job",fields:{jobId:{type:o.String_unsecure(),isOptional:!1},completedAt:{type:o.DateTime(),isOptional:!0},notes:{type:o.String_unsecure(),isOptional:!0}}});import{defineCommand as Z,defineQuery as r}from"@contractspec/lib.contracts-spec";import{defineSchemaModel as _,ScalarTypeEnum as Q}from"@contractspec/lib.schema";var H=["@examples.service-business-os"],$=_({name:"ListJobsInput",description:"Input for listing jobs",fields:{status:{type:Q.String_unsecure(),isOptional:!0},clientId:{type:Q.String_unsecure(),isOptional:!0},limit:{type:Q.Int_unsecure(),isOptional:!0},offset:{type:Q.Int_unsecure(),isOptional:!0}}}),j=_({name:"ListJobsOutput",description:"Output for listing jobs",fields:{jobs:{type:J,isOptional:!1,isList:!0},total:{type:Q.Int_unsecure(),isOptional:!1}}}),u=r({meta:{key:"service.job.list",version:"1.0.0",stability:"stable",owners:[...H],tags:["service-business-os","job","list","query"],description:"List all jobs with filtering",goal:"Retrieve list of jobs",context:"Job management"},io:{input:$,output:j},policy:{auth:"user"},acceptance:{scenarios:[{key:"list-jobs-happy-path",given:["Jobs exist"],when:["User lists jobs"],then:["List of jobs is returned"]}],examples:[{key:"list-active",input:{status:"scheduled",limit:10},output:{jobs:[],total:5}}]}}),q=Z({meta:{key:"service.job.schedule",version:"1.0.0",stability:"stable",owners:[...H],tags:["service-business-os","job","schedule"],description:"Schedule a job.",goal:"Schedule work.",context:"Job scheduling."},io:{input:w,output:J},policy:{auth:"user"},acceptance:{scenarios:[{key:"schedule-job-happy-path",given:["Client exists"],when:["User schedules job"],then:["Job is created with status SCHEDULED"]}],examples:[{key:"schedule-repair",input:{clientId:"client-123",date:"2025-01-20T10:00:00Z",type:"repair"},output:{id:"job-456",status:"scheduled"}}]}}),b=Z({meta:{key:"service.job.complete",version:"1.0.0",stability:"stable",owners:[...H],tags:["service-business-os","job","complete"],description:"Mark a job as complete.",goal:"Record job completion.",context:"Job management."},io:{input:L,output:J},policy:{auth:"user"},acceptance:{scenarios:[{key:"complete-job-happy-path",given:["Job is scheduled"],when:["User completes job"],then:["Job status becomes COMPLETED"]}],examples:[{key:"mark-complete",input:{jobId:"job-456",notes:"Done successfully"},output:{id:"job-456",status:"completed"}}]}});import{defineSchemaModel as R,ScalarTypeEnum as I}from"@contractspec/lib.schema";var z=R({name:"Payment",description:"Payment applied to invoice",fields:{id:{type:I.String_unsecure(),isOptional:!1},invoiceId:{type:I.String_unsecure(),isOptional:!1},amount:{type:I.Float_unsecure(),isOptional:!1},currency:{type:I.String_unsecure(),isOptional:!1},method:{type:I.String_unsecure(),isOptional:!1},reference:{type:I.String_unsecure(),isOptional:!0},receivedAt:{type:I.DateTime(),isOptional:!1}}}),B=R({name:"RecordPaymentInput",description:"Input for recording a payment",fields:{invoiceId:{type:I.String_unsecure(),isOptional:!1},amount:{type:I.Float_unsecure(),isOptional:!1},method:{type:I.String_unsecure(),isOptional:!1},reference:{type:I.String_unsecure(),isOptional:!0},receivedAt:{type:I.DateTime(),isOptional:!0}}});import{defineCommand as p}from"@contractspec/lib.contracts-spec";var y=["@examples.service-business-os"],M=p({meta:{key:"service.payment.record",version:"1.0.0",stability:"stable",owners:[...y],tags:["service-business-os","payment","record"],description:"Record a payment.",goal:"Track payments.",context:"Billing."},io:{input:B,output:z},policy:{auth:"user"},acceptance:{scenarios:[{key:"record-payment-happy-path",given:["Invoice exists"],when:["User records payment"],then:["Payment is recorded"]}],examples:[{key:"record-check",input:{invoiceId:"inv-456",amount:100,method:"check"},output:{id:"pay-123",status:"completed"}}]}});import{defineSchemaModel as K,ScalarTypeEnum as t}from"@contractspec/lib.schema";var P=K({name:"Quote",description:"Quote/proposal",fields:{id:{type:t.String_unsecure(),isOptional:!1},clientId:{type:t.String_unsecure(),isOptional:!1},title:{type:t.String_unsecure(),isOptional:!1},description:{type:t.String_unsecure(),isOptional:!0},amount:{type:t.Float_unsecure(),isOptional:!1},currency:{type:t.String_unsecure(),isOptional:!1},status:{type:t.String_unsecure(),isOptional:!1},validUntil:{type:t.DateTime(),isOptional:!0},createdAt:{type:t.DateTime(),isOptional:!1}}}),D=K({name:"CreateQuoteInput",description:"Input for creating a quote",fields:{clientId:{type:t.String_unsecure(),isOptional:!1},title:{type:t.String_unsecure(),isOptional:!1},description:{type:t.String_unsecure(),isOptional:!0},amount:{type:t.Float_unsecure(),isOptional:!1},currency:{type:t.String_unsecure(),isOptional:!0},validUntil:{type:t.DateTime(),isOptional:!0},orgId:{type:t.String_unsecure(),isOptional:!1},ownerId:{type:t.String_unsecure(),isOptional:!1}}}),F=K({name:"AcceptQuoteInput",description:"Input for accepting a quote",fields:{quoteId:{type:t.String_unsecure(),isOptional:!1},acceptedBy:{type:t.String_unsecure(),isOptional:!1},notes:{type:t.String_unsecure(),isOptional:!0}}});import{defineCommand as O}from"@contractspec/lib.contracts-spec";var N=["@examples.service-business-os"],W=O({meta:{key:"service.quote.create",version:"1.0.0",stability:"stable",owners:[...N],tags:["service-business-os","quote","create"],description:"Create a quote/proposal.",goal:"Quote clients.",context:"Quote creation."},io:{input:D,output:P},policy:{auth:"user"},acceptance:{scenarios:[{key:"create-quote-happy-path",given:["Client exists"],when:["User creates quote"],then:["Quote is created"]}],examples:[{key:"create-proposal",input:{clientId:"client-123",items:[{description:"Project A",price:5000}]},output:{id:"quote-123",status:"draft",total:5000}}]}}),f=O({meta:{key:"service.quote.accept",version:"1.0.0",stability:"stable",owners:[...N],tags:["service-business-os","quote","accept"],description:"Accept a quote.",goal:"Confirm quote.",context:"Quote acceptance."},io:{input:F,output:P},policy:{auth:"user"},acceptance:{scenarios:[{key:"accept-quote-happy-path",given:["Quote is open"],when:["Client accepts quote"],then:["Quote status becomes ACCEPTED"]}],examples:[{key:"client-accepts",input:{quoteId:"quote-123",signature:"John Doe"},output:{id:"quote-123",status:"accepted"}}]}});export{w as ScheduleJobInputModel,q as ScheduleJobContract,B as RecordPaymentInputModel,M as RecordPaymentContract,P as QuoteModel,z as PaymentModel,J as JobModel,k as IssueInvoiceInputModel,Y as IssueInvoiceContract,g as InvoiceModel,D as CreateQuoteInputModel,W as CreateQuoteContract,A as CreateClientInputModel,V as CreateClientContract,L as CompleteJobInputModel,b as CompleteJobContract,v as ClientModel,F as AcceptQuoteInputModel,f as AcceptQuoteContract};
|
package/dist/payment/index.js
CHANGED
|
@@ -1,70 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
|
|
3
|
-
import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
|
|
4
|
-
var PaymentModel = defineSchemaModel({
|
|
5
|
-
name: "Payment",
|
|
6
|
-
description: "Payment applied to invoice",
|
|
7
|
-
fields: {
|
|
8
|
-
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
9
|
-
invoiceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
10
|
-
amount: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
11
|
-
currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
12
|
-
method: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
13
|
-
reference: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
14
|
-
receivedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
var RecordPaymentInputModel = defineSchemaModel({
|
|
18
|
-
name: "RecordPaymentInput",
|
|
19
|
-
description: "Input for recording a payment",
|
|
20
|
-
fields: {
|
|
21
|
-
invoiceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
22
|
-
amount: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
23
|
-
method: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
24
|
-
reference: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
25
|
-
receivedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true }
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
// src/payment/payment.operations.ts
|
|
30
|
-
import { defineCommand } from "@contractspec/lib.contracts-spec";
|
|
31
|
-
var OWNERS = ["@examples.service-business-os"];
|
|
32
|
-
var RecordPaymentContract = defineCommand({
|
|
33
|
-
meta: {
|
|
34
|
-
key: "service.payment.record",
|
|
35
|
-
version: "1.0.0",
|
|
36
|
-
stability: "stable",
|
|
37
|
-
owners: [...OWNERS],
|
|
38
|
-
tags: ["service-business-os", "payment", "record"],
|
|
39
|
-
description: "Record a payment.",
|
|
40
|
-
goal: "Track payments.",
|
|
41
|
-
context: "Billing."
|
|
42
|
-
},
|
|
43
|
-
io: {
|
|
44
|
-
input: RecordPaymentInputModel,
|
|
45
|
-
output: PaymentModel
|
|
46
|
-
},
|
|
47
|
-
policy: { auth: "user" },
|
|
48
|
-
acceptance: {
|
|
49
|
-
scenarios: [
|
|
50
|
-
{
|
|
51
|
-
key: "record-payment-happy-path",
|
|
52
|
-
given: ["Invoice exists"],
|
|
53
|
-
when: ["User records payment"],
|
|
54
|
-
then: ["Payment is recorded"]
|
|
55
|
-
}
|
|
56
|
-
],
|
|
57
|
-
examples: [
|
|
58
|
-
{
|
|
59
|
-
key: "record-check",
|
|
60
|
-
input: { invoiceId: "inv-456", amount: 100, method: "check" },
|
|
61
|
-
output: { id: "pay-123", status: "completed" }
|
|
62
|
-
}
|
|
63
|
-
]
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
export {
|
|
67
|
-
RecordPaymentInputModel,
|
|
68
|
-
RecordPaymentContract,
|
|
69
|
-
PaymentModel
|
|
70
|
-
};
|
|
2
|
+
import{defineSchemaModel as j,ScalarTypeEnum as P}from"@contractspec/lib.schema";var x=j({name:"Payment",description:"Payment applied to invoice",fields:{id:{type:P.String_unsecure(),isOptional:!1},invoiceId:{type:P.String_unsecure(),isOptional:!1},amount:{type:P.Float_unsecure(),isOptional:!1},currency:{type:P.String_unsecure(),isOptional:!1},method:{type:P.String_unsecure(),isOptional:!1},reference:{type:P.String_unsecure(),isOptional:!0},receivedAt:{type:P.DateTime(),isOptional:!1}}}),g=j({name:"RecordPaymentInput",description:"Input for recording a payment",fields:{invoiceId:{type:P.String_unsecure(),isOptional:!1},amount:{type:P.Float_unsecure(),isOptional:!1},method:{type:P.String_unsecure(),isOptional:!1},reference:{type:P.String_unsecure(),isOptional:!0},receivedAt:{type:P.DateTime(),isOptional:!0}}});import{defineCommand as k}from"@contractspec/lib.contracts-spec";var q=["@examples.service-business-os"],v=k({meta:{key:"service.payment.record",version:"1.0.0",stability:"stable",owners:[...q],tags:["service-business-os","payment","record"],description:"Record a payment.",goal:"Track payments.",context:"Billing."},io:{input:g,output:x},policy:{auth:"user"},acceptance:{scenarios:[{key:"record-payment-happy-path",given:["Invoice exists"],when:["User records payment"],then:["Payment is recorded"]}],examples:[{key:"record-check",input:{invoiceId:"inv-456",amount:100,method:"check"},output:{id:"pay-123",status:"completed"}}]}});export{g as RecordPaymentInputModel,v as RecordPaymentContract,x as PaymentModel};
|
|
@@ -1,68 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
|
|
3
|
-
import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
|
|
4
|
-
var PaymentModel = defineSchemaModel({
|
|
5
|
-
name: "Payment",
|
|
6
|
-
description: "Payment applied to invoice",
|
|
7
|
-
fields: {
|
|
8
|
-
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
9
|
-
invoiceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
10
|
-
amount: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
11
|
-
currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
12
|
-
method: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
13
|
-
reference: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
14
|
-
receivedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
var RecordPaymentInputModel = defineSchemaModel({
|
|
18
|
-
name: "RecordPaymentInput",
|
|
19
|
-
description: "Input for recording a payment",
|
|
20
|
-
fields: {
|
|
21
|
-
invoiceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
22
|
-
amount: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
23
|
-
method: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
24
|
-
reference: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
25
|
-
receivedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true }
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
// src/payment/payment.operations.ts
|
|
30
|
-
import { defineCommand } from "@contractspec/lib.contracts-spec";
|
|
31
|
-
var OWNERS = ["@examples.service-business-os"];
|
|
32
|
-
var RecordPaymentContract = defineCommand({
|
|
33
|
-
meta: {
|
|
34
|
-
key: "service.payment.record",
|
|
35
|
-
version: "1.0.0",
|
|
36
|
-
stability: "stable",
|
|
37
|
-
owners: [...OWNERS],
|
|
38
|
-
tags: ["service-business-os", "payment", "record"],
|
|
39
|
-
description: "Record a payment.",
|
|
40
|
-
goal: "Track payments.",
|
|
41
|
-
context: "Billing."
|
|
42
|
-
},
|
|
43
|
-
io: {
|
|
44
|
-
input: RecordPaymentInputModel,
|
|
45
|
-
output: PaymentModel
|
|
46
|
-
},
|
|
47
|
-
policy: { auth: "user" },
|
|
48
|
-
acceptance: {
|
|
49
|
-
scenarios: [
|
|
50
|
-
{
|
|
51
|
-
key: "record-payment-happy-path",
|
|
52
|
-
given: ["Invoice exists"],
|
|
53
|
-
when: ["User records payment"],
|
|
54
|
-
then: ["Payment is recorded"]
|
|
55
|
-
}
|
|
56
|
-
],
|
|
57
|
-
examples: [
|
|
58
|
-
{
|
|
59
|
-
key: "record-check",
|
|
60
|
-
input: { invoiceId: "inv-456", amount: 100, method: "check" },
|
|
61
|
-
output: { id: "pay-123", status: "completed" }
|
|
62
|
-
}
|
|
63
|
-
]
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
export {
|
|
67
|
-
RecordPaymentContract
|
|
68
|
-
};
|
|
2
|
+
import{defineSchemaModel as k,ScalarTypeEnum as j}from"@contractspec/lib.schema";var q=k({name:"Payment",description:"Payment applied to invoice",fields:{id:{type:j.String_unsecure(),isOptional:!1},invoiceId:{type:j.String_unsecure(),isOptional:!1},amount:{type:j.Float_unsecure(),isOptional:!1},currency:{type:j.String_unsecure(),isOptional:!1},method:{type:j.String_unsecure(),isOptional:!1},reference:{type:j.String_unsecure(),isOptional:!0},receivedAt:{type:j.DateTime(),isOptional:!1}}}),v=k({name:"RecordPaymentInput",description:"Input for recording a payment",fields:{invoiceId:{type:j.String_unsecure(),isOptional:!1},amount:{type:j.Float_unsecure(),isOptional:!1},method:{type:j.String_unsecure(),isOptional:!1},reference:{type:j.String_unsecure(),isOptional:!0},receivedAt:{type:j.DateTime(),isOptional:!0}}});import{defineCommand as w}from"@contractspec/lib.contracts-spec";var x=["@examples.service-business-os"],F=w({meta:{key:"service.payment.record",version:"1.0.0",stability:"stable",owners:[...x],tags:["service-business-os","payment","record"],description:"Record a payment.",goal:"Track payments.",context:"Billing."},io:{input:v,output:q},policy:{auth:"user"},acceptance:{scenarios:[{key:"record-payment-happy-path",given:["Invoice exists"],when:["User records payment"],then:["Payment is recorded"]}],examples:[{key:"record-check",input:{invoiceId:"inv-456",amount:100,method:"check"},output:{id:"pay-123",status:"completed"}}]}});export{F as RecordPaymentContract};
|