@contractspec/example.service-business-os 1.56.1 → 1.58.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/dist/browser/client/client.operations.js +72 -0
- package/dist/browser/client/client.schema.js +31 -0
- package/dist/browser/client/index.js +74 -0
- package/dist/browser/docs/index.js +96 -0
- package/dist/browser/docs/service-business-os.docblock.js +96 -0
- package/dist/browser/entities/index.js +246 -0
- package/dist/browser/events.js +135 -0
- package/dist/browser/example.js +39 -0
- package/dist/browser/handlers/index.js +5 -0
- package/dist/browser/index.js +752 -0
- package/dist/browser/invoice/index.js +77 -0
- package/dist/browser/invoice/invoice.operations.js +75 -0
- package/dist/browser/invoice/invoice.schema.js +34 -0
- package/dist/browser/job/index.js +175 -0
- package/dist/browser/job/job.operations.js +172 -0
- package/dist/browser/job/job.schema.js +41 -0
- package/dist/browser/operations/index.js +506 -0
- package/dist/browser/payment/index.js +69 -0
- package/dist/browser/payment/payment.operations.js +67 -0
- package/dist/browser/payment/payment.schema.js +30 -0
- package/dist/browser/presentations/index.js +13 -0
- package/dist/browser/presentations.js +172 -0
- package/dist/browser/quote/index.js +122 -0
- package/dist/browser/quote/quote.operations.js +119 -0
- package/dist/browser/quote/quote.schema.js +45 -0
- package/dist/browser/service-business-os.capability.js +28 -0
- package/dist/browser/service.feature.js +74 -0
- package/dist/client/client.operations.d.ts +54 -60
- package/dist/client/client.operations.d.ts.map +1 -1
- package/dist/client/client.operations.js +71 -51
- package/dist/client/client.schema.d.ts +54 -59
- package/dist/client/client.schema.d.ts.map +1 -1
- package/dist/client/client.schema.js +30 -75
- package/dist/client/index.d.ts +6 -3
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +74 -3
- package/dist/docs/index.d.ts +2 -1
- package/dist/docs/index.d.ts.map +1 -0
- package/dist/docs/index.js +97 -1
- package/dist/docs/service-business-os.docblock.d.ts +2 -1
- package/dist/docs/service-business-os.docblock.d.ts.map +1 -0
- package/dist/docs/service-business-os.docblock.js +52 -64
- package/dist/entities/index.d.ts +156 -161
- package/dist/entities/index.d.ts.map +1 -1
- package/dist/entities/index.js +236 -278
- package/dist/events.d.ts +253 -259
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +123 -217
- package/dist/example.d.ts +2 -6
- package/dist/example.d.ts.map +1 -1
- package/dist/example.js +37 -50
- package/dist/handlers/index.d.ts +11 -16
- package/dist/handlers/index.d.ts.map +1 -1
- package/dist/handlers/index.js +5 -5
- package/dist/index.d.ts +13 -18
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +752 -18
- package/dist/invoice/index.d.ts +6 -3
- package/dist/invoice/index.d.ts.map +1 -0
- package/dist/invoice/index.js +77 -3
- package/dist/invoice/invoice.operations.d.ts +54 -60
- package/dist/invoice/invoice.operations.d.ts.map +1 -1
- package/dist/invoice/invoice.operations.js +74 -55
- package/dist/invoice/invoice.schema.d.ts +54 -59
- package/dist/invoice/invoice.schema.d.ts.map +1 -1
- package/dist/invoice/invoice.schema.js +33 -75
- package/dist/job/index.d.ts +6 -3
- package/dist/job/index.d.ts.map +1 -0
- package/dist/job/index.js +175 -3
- package/dist/job/job.operations.d.ts +220 -226
- package/dist/job/job.operations.d.ts.map +1 -1
- package/dist/job/job.operations.js +167 -169
- package/dist/job/job.schema.d.ts +67 -72
- package/dist/job/job.schema.d.ts.map +1 -1
- package/dist/job/job.schema.js +39 -95
- package/dist/node/client/client.operations.js +72 -0
- package/dist/node/client/client.schema.js +31 -0
- package/dist/node/client/index.js +74 -0
- package/dist/node/docs/index.js +96 -0
- package/dist/node/docs/service-business-os.docblock.js +96 -0
- package/dist/node/entities/index.js +246 -0
- package/dist/node/events.js +135 -0
- package/dist/node/example.js +39 -0
- package/dist/node/handlers/index.js +5 -0
- package/dist/node/index.js +752 -0
- package/dist/node/invoice/index.js +77 -0
- package/dist/node/invoice/invoice.operations.js +75 -0
- package/dist/node/invoice/invoice.schema.js +34 -0
- package/dist/node/job/index.js +175 -0
- package/dist/node/job/job.operations.js +172 -0
- package/dist/node/job/job.schema.js +41 -0
- package/dist/node/operations/index.js +506 -0
- package/dist/node/payment/index.js +69 -0
- package/dist/node/payment/payment.operations.js +67 -0
- package/dist/node/payment/payment.schema.js +30 -0
- package/dist/node/presentations/index.js +13 -0
- package/dist/node/presentations.js +172 -0
- package/dist/node/quote/index.js +122 -0
- package/dist/node/quote/quote.operations.js +119 -0
- package/dist/node/quote/quote.schema.js +45 -0
- package/dist/node/service-business-os.capability.js +28 -0
- package/dist/node/service.feature.js +74 -0
- package/dist/operations/index.d.ts +6 -16
- package/dist/operations/index.d.ts.map +1 -0
- package/dist/operations/index.js +506 -16
- package/dist/payment/index.d.ts +6 -3
- package/dist/payment/index.d.ts.map +1 -0
- package/dist/payment/index.js +69 -3
- package/dist/payment/payment.operations.d.ts +50 -56
- package/dist/payment/payment.operations.d.ts.map +1 -1
- package/dist/payment/payment.operations.js +66 -51
- package/dist/payment/payment.schema.d.ts +50 -55
- package/dist/payment/payment.schema.d.ts.map +1 -1
- package/dist/payment/payment.schema.js +29 -71
- package/dist/presentations/index.d.ts +1 -4
- package/dist/presentations/index.d.ts.map +1 -1
- package/dist/presentations/index.js +13 -17
- package/dist/presentations.d.ts +7 -12
- package/dist/presentations.d.ts.map +1 -1
- package/dist/presentations.js +166 -172
- package/dist/quote/index.d.ts +6 -3
- package/dist/quote/index.d.ts.map +1 -0
- package/dist/quote/index.js +122 -3
- package/dist/quote/quote.operations.d.ts +120 -126
- package/dist/quote/quote.operations.d.ts.map +1 -1
- package/dist/quote/quote.operations.js +117 -96
- package/dist/quote/quote.schema.d.ts +83 -88
- package/dist/quote/quote.schema.d.ts.map +1 -1
- package/dist/quote/quote.schema.js +43 -111
- package/dist/service-business-os.capability.d.ts +2 -7
- package/dist/service-business-os.capability.d.ts.map +1 -1
- package/dist/service-business-os.capability.js +29 -29
- package/dist/service.feature.d.ts +1 -6
- package/dist/service.feature.d.ts.map +1 -1
- package/dist/service.feature.js +73 -164
- package/package.json +301 -64
- package/dist/client/client.operations.js.map +0 -1
- package/dist/client/client.schema.js.map +0 -1
- package/dist/docs/service-business-os.docblock.js.map +0 -1
- package/dist/entities/index.js.map +0 -1
- package/dist/events.js.map +0 -1
- package/dist/example.js.map +0 -1
- package/dist/handlers/index.js.map +0 -1
- package/dist/invoice/invoice.operations.js.map +0 -1
- package/dist/invoice/invoice.schema.js.map +0 -1
- package/dist/job/job.operations.js.map +0 -1
- package/dist/job/job.schema.js.map +0 -1
- package/dist/payment/payment.operations.js.map +0 -1
- package/dist/payment/payment.schema.js.map +0 -1
- package/dist/presentations/index.js.map +0 -1
- package/dist/presentations.js.map +0 -1
- package/dist/quote/quote.operations.js.map +0 -1
- package/dist/quote/quote.schema.js.map +0 -1
- package/dist/service-business-os.capability.js.map +0 -1
- package/dist/service.feature.js.map +0 -1
package/dist/operations/index.js
CHANGED
|
@@ -1,17 +1,507 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import "
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
+
});
|
|
16
29
|
|
|
17
|
-
|
|
30
|
+
// src/client/client.operations.ts
|
|
31
|
+
import { defineCommand } from "@contractspec/lib.contracts";
|
|
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/quote/quote.schema.ts
|
|
72
|
+
import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
|
|
73
|
+
var QuoteModel = defineSchemaModel2({
|
|
74
|
+
name: "Quote",
|
|
75
|
+
description: "Quote/proposal",
|
|
76
|
+
fields: {
|
|
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 },
|
|
81
|
+
amount: { type: ScalarTypeEnum2.Float_unsecure(), isOptional: false },
|
|
82
|
+
currency: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
83
|
+
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 }
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
var AcceptQuoteInputModel = defineSchemaModel2({
|
|
103
|
+
name: "AcceptQuoteInput",
|
|
104
|
+
description: "Input for accepting a quote",
|
|
105
|
+
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 }
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// src/quote/quote.operations.ts
|
|
113
|
+
import { defineCommand as defineCommand2 } from "@contractspec/lib.contracts";
|
|
114
|
+
var OWNERS2 = ["@examples.service-business-os"];
|
|
115
|
+
var CreateQuoteContract = defineCommand2({
|
|
116
|
+
meta: {
|
|
117
|
+
key: "service.quote.create",
|
|
118
|
+
version: "1.0.0",
|
|
119
|
+
stability: "stable",
|
|
120
|
+
owners: [...OWNERS2],
|
|
121
|
+
tags: ["service-business-os", "quote", "create"],
|
|
122
|
+
description: "Create a quote/proposal.",
|
|
123
|
+
goal: "Quote clients.",
|
|
124
|
+
context: "Quote creation."
|
|
125
|
+
},
|
|
126
|
+
io: {
|
|
127
|
+
input: CreateQuoteInputModel,
|
|
128
|
+
output: QuoteModel
|
|
129
|
+
},
|
|
130
|
+
policy: { auth: "user" },
|
|
131
|
+
acceptance: {
|
|
132
|
+
scenarios: [
|
|
133
|
+
{
|
|
134
|
+
key: "create-quote-happy-path",
|
|
135
|
+
given: ["Client exists"],
|
|
136
|
+
when: ["User creates quote"],
|
|
137
|
+
then: ["Quote is created"]
|
|
138
|
+
}
|
|
139
|
+
],
|
|
140
|
+
examples: [
|
|
141
|
+
{
|
|
142
|
+
key: "create-proposal",
|
|
143
|
+
input: {
|
|
144
|
+
clientId: "client-123",
|
|
145
|
+
items: [{ description: "Project A", price: 5000 }]
|
|
146
|
+
},
|
|
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" }
|
|
182
|
+
}
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
// src/job/job.schema.ts
|
|
187
|
+
import { defineSchemaModel as defineSchemaModel3, ScalarTypeEnum as ScalarTypeEnum3 } from "@contractspec/lib.schema";
|
|
188
|
+
var JobModel = defineSchemaModel3({
|
|
189
|
+
name: "Job",
|
|
190
|
+
description: "Scheduled job",
|
|
191
|
+
fields: {
|
|
192
|
+
id: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
193
|
+
quoteId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
194
|
+
clientId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
195
|
+
title: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
196
|
+
status: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
197
|
+
scheduledAt: { type: ScalarTypeEnum3.DateTime(), isOptional: true },
|
|
198
|
+
completedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: true },
|
|
199
|
+
assignedTo: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true }
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
var ScheduleJobInputModel = defineSchemaModel3({
|
|
203
|
+
name: "ScheduleJobInput",
|
|
204
|
+
description: "Input for scheduling a job",
|
|
205
|
+
fields: {
|
|
206
|
+
quoteId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
207
|
+
scheduledAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false },
|
|
208
|
+
assignedTo: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
|
|
209
|
+
location: { type: ScalarTypeEnum3.JSON(), isOptional: true },
|
|
210
|
+
title: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true }
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
var CompleteJobInputModel = defineSchemaModel3({
|
|
214
|
+
name: "CompleteJobInput",
|
|
215
|
+
description: "Input for completing a job",
|
|
216
|
+
fields: {
|
|
217
|
+
jobId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
218
|
+
completedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: true },
|
|
219
|
+
notes: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true }
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
// src/job/job.operations.ts
|
|
224
|
+
import { defineCommand as defineCommand3, defineQuery } from "@contractspec/lib.contracts";
|
|
225
|
+
import { defineSchemaModel as defineSchemaModel4, ScalarTypeEnum as ScalarTypeEnum4 } from "@contractspec/lib.schema";
|
|
226
|
+
var OWNERS3 = ["@examples.service-business-os"];
|
|
227
|
+
var ListJobsInputModel = defineSchemaModel4({
|
|
228
|
+
name: "ListJobsInput",
|
|
229
|
+
description: "Input for listing jobs",
|
|
230
|
+
fields: {
|
|
231
|
+
status: { type: ScalarTypeEnum4.String_unsecure(), isOptional: true },
|
|
232
|
+
clientId: { type: ScalarTypeEnum4.String_unsecure(), isOptional: true },
|
|
233
|
+
limit: { type: ScalarTypeEnum4.Int_unsecure(), isOptional: true },
|
|
234
|
+
offset: { type: ScalarTypeEnum4.Int_unsecure(), isOptional: true }
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
var ListJobsOutputModel = defineSchemaModel4({
|
|
238
|
+
name: "ListJobsOutput",
|
|
239
|
+
description: "Output for listing jobs",
|
|
240
|
+
fields: {
|
|
241
|
+
jobs: { type: JobModel, isOptional: false, isList: true },
|
|
242
|
+
total: { type: ScalarTypeEnum4.Int_unsecure(), isOptional: false }
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
var ListJobsOperation = defineQuery({
|
|
246
|
+
meta: {
|
|
247
|
+
key: "service.job.list",
|
|
248
|
+
version: "1.0.0",
|
|
249
|
+
stability: "stable",
|
|
250
|
+
owners: [...OWNERS3],
|
|
251
|
+
tags: ["service-business-os", "job", "list", "query"],
|
|
252
|
+
description: "List all jobs with filtering",
|
|
253
|
+
goal: "Retrieve list of jobs",
|
|
254
|
+
context: "Job management"
|
|
255
|
+
},
|
|
256
|
+
io: {
|
|
257
|
+
input: ListJobsInputModel,
|
|
258
|
+
output: ListJobsOutputModel
|
|
259
|
+
},
|
|
260
|
+
policy: { auth: "user" },
|
|
261
|
+
acceptance: {
|
|
262
|
+
scenarios: [
|
|
263
|
+
{
|
|
264
|
+
key: "list-jobs-happy-path",
|
|
265
|
+
given: ["Jobs exist"],
|
|
266
|
+
when: ["User lists jobs"],
|
|
267
|
+
then: ["List of jobs is returned"]
|
|
268
|
+
}
|
|
269
|
+
],
|
|
270
|
+
examples: [
|
|
271
|
+
{
|
|
272
|
+
key: "list-active",
|
|
273
|
+
input: { status: "scheduled", limit: 10 },
|
|
274
|
+
output: { jobs: [], total: 5 }
|
|
275
|
+
}
|
|
276
|
+
]
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
var ScheduleJobContract = defineCommand3({
|
|
280
|
+
meta: {
|
|
281
|
+
key: "service.job.schedule",
|
|
282
|
+
version: "1.0.0",
|
|
283
|
+
stability: "stable",
|
|
284
|
+
owners: [...OWNERS3],
|
|
285
|
+
tags: ["service-business-os", "job", "schedule"],
|
|
286
|
+
description: "Schedule a job.",
|
|
287
|
+
goal: "Schedule work.",
|
|
288
|
+
context: "Job scheduling."
|
|
289
|
+
},
|
|
290
|
+
io: {
|
|
291
|
+
input: ScheduleJobInputModel,
|
|
292
|
+
output: JobModel
|
|
293
|
+
},
|
|
294
|
+
policy: { auth: "user" },
|
|
295
|
+
acceptance: {
|
|
296
|
+
scenarios: [
|
|
297
|
+
{
|
|
298
|
+
key: "schedule-job-happy-path",
|
|
299
|
+
given: ["Client exists"],
|
|
300
|
+
when: ["User schedules job"],
|
|
301
|
+
then: ["Job is created with status SCHEDULED"]
|
|
302
|
+
}
|
|
303
|
+
],
|
|
304
|
+
examples: [
|
|
305
|
+
{
|
|
306
|
+
key: "schedule-repair",
|
|
307
|
+
input: {
|
|
308
|
+
clientId: "client-123",
|
|
309
|
+
date: "2025-01-20T10:00:00Z",
|
|
310
|
+
type: "repair"
|
|
311
|
+
},
|
|
312
|
+
output: { id: "job-456", status: "scheduled" }
|
|
313
|
+
}
|
|
314
|
+
]
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
var CompleteJobContract = defineCommand3({
|
|
318
|
+
meta: {
|
|
319
|
+
key: "service.job.complete",
|
|
320
|
+
version: "1.0.0",
|
|
321
|
+
stability: "stable",
|
|
322
|
+
owners: [...OWNERS3],
|
|
323
|
+
tags: ["service-business-os", "job", "complete"],
|
|
324
|
+
description: "Mark a job as complete.",
|
|
325
|
+
goal: "Record job completion.",
|
|
326
|
+
context: "Job management."
|
|
327
|
+
},
|
|
328
|
+
io: {
|
|
329
|
+
input: CompleteJobInputModel,
|
|
330
|
+
output: JobModel
|
|
331
|
+
},
|
|
332
|
+
policy: { auth: "user" },
|
|
333
|
+
acceptance: {
|
|
334
|
+
scenarios: [
|
|
335
|
+
{
|
|
336
|
+
key: "complete-job-happy-path",
|
|
337
|
+
given: ["Job is scheduled"],
|
|
338
|
+
when: ["User completes job"],
|
|
339
|
+
then: ["Job status becomes COMPLETED"]
|
|
340
|
+
}
|
|
341
|
+
],
|
|
342
|
+
examples: [
|
|
343
|
+
{
|
|
344
|
+
key: "mark-complete",
|
|
345
|
+
input: { jobId: "job-456", notes: "Done successfully" },
|
|
346
|
+
output: { id: "job-456", status: "completed" }
|
|
347
|
+
}
|
|
348
|
+
]
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
// src/invoice/invoice.schema.ts
|
|
352
|
+
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",
|
|
356
|
+
fields: {
|
|
357
|
+
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
|
+
},
|
|
363
|
+
amount: { type: ScalarTypeEnum5.Float_unsecure(), isOptional: false },
|
|
364
|
+
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";
|
|
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 }
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
var RecordPaymentInputModel = defineSchemaModel6({
|
|
439
|
+
name: "RecordPaymentInput",
|
|
440
|
+
description: "Input for recording a payment",
|
|
441
|
+
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 }
|
|
447
|
+
}
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
// src/payment/payment.operations.ts
|
|
451
|
+
import { defineCommand as defineCommand5 } from "@contractspec/lib.contracts";
|
|
452
|
+
var OWNERS5 = ["@examples.service-business-os"];
|
|
453
|
+
var RecordPaymentContract = defineCommand5({
|
|
454
|
+
meta: {
|
|
455
|
+
key: "service.payment.record",
|
|
456
|
+
version: "1.0.0",
|
|
457
|
+
stability: "stable",
|
|
458
|
+
owners: [...OWNERS5],
|
|
459
|
+
tags: ["service-business-os", "payment", "record"],
|
|
460
|
+
description: "Record a payment.",
|
|
461
|
+
goal: "Track payments.",
|
|
462
|
+
context: "Billing."
|
|
463
|
+
},
|
|
464
|
+
io: {
|
|
465
|
+
input: RecordPaymentInputModel,
|
|
466
|
+
output: PaymentModel
|
|
467
|
+
},
|
|
468
|
+
policy: { auth: "user" },
|
|
469
|
+
acceptance: {
|
|
470
|
+
scenarios: [
|
|
471
|
+
{
|
|
472
|
+
key: "record-payment-happy-path",
|
|
473
|
+
given: ["Invoice exists"],
|
|
474
|
+
when: ["User records payment"],
|
|
475
|
+
then: ["Payment is recorded"]
|
|
476
|
+
}
|
|
477
|
+
],
|
|
478
|
+
examples: [
|
|
479
|
+
{
|
|
480
|
+
key: "record-check",
|
|
481
|
+
input: { invoiceId: "inv-456", amount: 100, method: "check" },
|
|
482
|
+
output: { id: "pay-123", status: "completed" }
|
|
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
|
+
};
|
package/dist/payment/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Payment domain - Payment management.
|
|
3
|
+
*/
|
|
4
|
+
export { PaymentModel, RecordPaymentInputModel } from './payment.schema';
|
|
5
|
+
export { RecordPaymentContract } from './payment.operations';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/payment/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/payment/index.js
CHANGED
|
@@ -1,4 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// @bun
|
|
2
|
+
// src/payment/payment.schema.ts
|
|
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
|
+
});
|
|
3
28
|
|
|
4
|
-
|
|
29
|
+
// src/payment/payment.operations.ts
|
|
30
|
+
import { defineCommand } from "@contractspec/lib.contracts";
|
|
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
|
+
};
|