@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
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// src/invoice/invoice.schema.ts
|
|
2
|
+
import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
|
|
3
|
+
var InvoiceModel = defineSchemaModel({
|
|
4
|
+
name: "Invoice",
|
|
5
|
+
description: "Invoice issued for a job",
|
|
6
|
+
fields: {
|
|
7
|
+
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
8
|
+
jobId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
9
|
+
invoiceNumber: {
|
|
10
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
11
|
+
isOptional: false
|
|
12
|
+
},
|
|
13
|
+
amount: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
14
|
+
currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
15
|
+
status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
16
|
+
dueDate: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
17
|
+
issuedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
18
|
+
paidAt: { type: ScalarTypeEnum.DateTime(), isOptional: true }
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
var IssueInvoiceInputModel = defineSchemaModel({
|
|
22
|
+
name: "IssueInvoiceInput",
|
|
23
|
+
description: "Input for issuing an invoice",
|
|
24
|
+
fields: {
|
|
25
|
+
jobId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
26
|
+
dueDate: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
27
|
+
notes: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
28
|
+
lineItems: { type: ScalarTypeEnum.JSON(), isOptional: true }
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// src/invoice/invoice.operations.ts
|
|
33
|
+
import { defineCommand } from "@contractspec/lib.contracts";
|
|
34
|
+
var OWNERS = ["@examples.service-business-os"];
|
|
35
|
+
var IssueInvoiceContract = defineCommand({
|
|
36
|
+
meta: {
|
|
37
|
+
key: "service.invoice.issue",
|
|
38
|
+
version: "1.0.0",
|
|
39
|
+
stability: "stable",
|
|
40
|
+
owners: [...OWNERS],
|
|
41
|
+
tags: ["service-business-os", "invoice", "issue"],
|
|
42
|
+
description: "Issue an invoice for a job.",
|
|
43
|
+
goal: "Bill clients.",
|
|
44
|
+
context: "Billing."
|
|
45
|
+
},
|
|
46
|
+
io: {
|
|
47
|
+
input: IssueInvoiceInputModel,
|
|
48
|
+
output: InvoiceModel
|
|
49
|
+
},
|
|
50
|
+
policy: { auth: "user" },
|
|
51
|
+
acceptance: {
|
|
52
|
+
scenarios: [
|
|
53
|
+
{
|
|
54
|
+
key: "issue-invoice-happy-path",
|
|
55
|
+
given: ["Job is complete"],
|
|
56
|
+
when: ["User issues invoice"],
|
|
57
|
+
then: ["Invoice is created and sent"]
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
examples: [
|
|
61
|
+
{
|
|
62
|
+
key: "issue-standard",
|
|
63
|
+
input: {
|
|
64
|
+
jobId: "job-123",
|
|
65
|
+
dueDate: "2025-02-01",
|
|
66
|
+
items: [{ description: "Service", amount: 100 }]
|
|
67
|
+
},
|
|
68
|
+
output: { id: "inv-456", status: "issued", total: 100 }
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
export {
|
|
74
|
+
IssueInvoiceInputModel,
|
|
75
|
+
IssueInvoiceContract,
|
|
76
|
+
InvoiceModel
|
|
77
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// src/invoice/invoice.schema.ts
|
|
2
|
+
import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
|
|
3
|
+
var InvoiceModel = defineSchemaModel({
|
|
4
|
+
name: "Invoice",
|
|
5
|
+
description: "Invoice issued for a job",
|
|
6
|
+
fields: {
|
|
7
|
+
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
8
|
+
jobId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
9
|
+
invoiceNumber: {
|
|
10
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
11
|
+
isOptional: false
|
|
12
|
+
},
|
|
13
|
+
amount: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
14
|
+
currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
15
|
+
status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
16
|
+
dueDate: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
17
|
+
issuedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
18
|
+
paidAt: { type: ScalarTypeEnum.DateTime(), isOptional: true }
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
var IssueInvoiceInputModel = defineSchemaModel({
|
|
22
|
+
name: "IssueInvoiceInput",
|
|
23
|
+
description: "Input for issuing an invoice",
|
|
24
|
+
fields: {
|
|
25
|
+
jobId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
26
|
+
dueDate: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
27
|
+
notes: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
28
|
+
lineItems: { type: ScalarTypeEnum.JSON(), isOptional: true }
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// src/invoice/invoice.operations.ts
|
|
33
|
+
import { defineCommand } from "@contractspec/lib.contracts";
|
|
34
|
+
var OWNERS = ["@examples.service-business-os"];
|
|
35
|
+
var IssueInvoiceContract = defineCommand({
|
|
36
|
+
meta: {
|
|
37
|
+
key: "service.invoice.issue",
|
|
38
|
+
version: "1.0.0",
|
|
39
|
+
stability: "stable",
|
|
40
|
+
owners: [...OWNERS],
|
|
41
|
+
tags: ["service-business-os", "invoice", "issue"],
|
|
42
|
+
description: "Issue an invoice for a job.",
|
|
43
|
+
goal: "Bill clients.",
|
|
44
|
+
context: "Billing."
|
|
45
|
+
},
|
|
46
|
+
io: {
|
|
47
|
+
input: IssueInvoiceInputModel,
|
|
48
|
+
output: InvoiceModel
|
|
49
|
+
},
|
|
50
|
+
policy: { auth: "user" },
|
|
51
|
+
acceptance: {
|
|
52
|
+
scenarios: [
|
|
53
|
+
{
|
|
54
|
+
key: "issue-invoice-happy-path",
|
|
55
|
+
given: ["Job is complete"],
|
|
56
|
+
when: ["User issues invoice"],
|
|
57
|
+
then: ["Invoice is created and sent"]
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
examples: [
|
|
61
|
+
{
|
|
62
|
+
key: "issue-standard",
|
|
63
|
+
input: {
|
|
64
|
+
jobId: "job-123",
|
|
65
|
+
dueDate: "2025-02-01",
|
|
66
|
+
items: [{ description: "Service", amount: 100 }]
|
|
67
|
+
},
|
|
68
|
+
output: { id: "inv-456", status: "issued", total: 100 }
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
export {
|
|
74
|
+
IssueInvoiceContract
|
|
75
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// src/invoice/invoice.schema.ts
|
|
2
|
+
import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
|
|
3
|
+
var InvoiceModel = defineSchemaModel({
|
|
4
|
+
name: "Invoice",
|
|
5
|
+
description: "Invoice issued for a job",
|
|
6
|
+
fields: {
|
|
7
|
+
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
8
|
+
jobId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
9
|
+
invoiceNumber: {
|
|
10
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
11
|
+
isOptional: false
|
|
12
|
+
},
|
|
13
|
+
amount: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
14
|
+
currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
15
|
+
status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
16
|
+
dueDate: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
17
|
+
issuedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
18
|
+
paidAt: { type: ScalarTypeEnum.DateTime(), isOptional: true }
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
var IssueInvoiceInputModel = defineSchemaModel({
|
|
22
|
+
name: "IssueInvoiceInput",
|
|
23
|
+
description: "Input for issuing an invoice",
|
|
24
|
+
fields: {
|
|
25
|
+
jobId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
26
|
+
dueDate: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
27
|
+
notes: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
28
|
+
lineItems: { type: ScalarTypeEnum.JSON(), isOptional: true }
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
export {
|
|
32
|
+
IssueInvoiceInputModel,
|
|
33
|
+
InvoiceModel
|
|
34
|
+
};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
// src/job/job.schema.ts
|
|
2
|
+
import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
|
|
3
|
+
var JobModel = defineSchemaModel({
|
|
4
|
+
name: "Job",
|
|
5
|
+
description: "Scheduled job",
|
|
6
|
+
fields: {
|
|
7
|
+
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
8
|
+
quoteId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
9
|
+
clientId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
10
|
+
title: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
11
|
+
status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
12
|
+
scheduledAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
13
|
+
completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
14
|
+
assignedTo: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
var ScheduleJobInputModel = defineSchemaModel({
|
|
18
|
+
name: "ScheduleJobInput",
|
|
19
|
+
description: "Input for scheduling a job",
|
|
20
|
+
fields: {
|
|
21
|
+
quoteId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
22
|
+
scheduledAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
23
|
+
assignedTo: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
24
|
+
location: { type: ScalarTypeEnum.JSON(), isOptional: true },
|
|
25
|
+
title: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
var CompleteJobInputModel = defineSchemaModel({
|
|
29
|
+
name: "CompleteJobInput",
|
|
30
|
+
description: "Input for completing a job",
|
|
31
|
+
fields: {
|
|
32
|
+
jobId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
33
|
+
completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
34
|
+
notes: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// src/job/job.operations.ts
|
|
39
|
+
import { defineCommand, defineQuery } from "@contractspec/lib.contracts";
|
|
40
|
+
import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
|
|
41
|
+
var OWNERS = ["@examples.service-business-os"];
|
|
42
|
+
var ListJobsInputModel = defineSchemaModel2({
|
|
43
|
+
name: "ListJobsInput",
|
|
44
|
+
description: "Input for listing jobs",
|
|
45
|
+
fields: {
|
|
46
|
+
status: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
47
|
+
clientId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
48
|
+
limit: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
|
|
49
|
+
offset: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true }
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
var ListJobsOutputModel = defineSchemaModel2({
|
|
53
|
+
name: "ListJobsOutput",
|
|
54
|
+
description: "Output for listing jobs",
|
|
55
|
+
fields: {
|
|
56
|
+
jobs: { type: JobModel, isOptional: false, isList: true },
|
|
57
|
+
total: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false }
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
var ListJobsOperation = defineQuery({
|
|
61
|
+
meta: {
|
|
62
|
+
key: "service.job.list",
|
|
63
|
+
version: "1.0.0",
|
|
64
|
+
stability: "stable",
|
|
65
|
+
owners: [...OWNERS],
|
|
66
|
+
tags: ["service-business-os", "job", "list", "query"],
|
|
67
|
+
description: "List all jobs with filtering",
|
|
68
|
+
goal: "Retrieve list of jobs",
|
|
69
|
+
context: "Job management"
|
|
70
|
+
},
|
|
71
|
+
io: {
|
|
72
|
+
input: ListJobsInputModel,
|
|
73
|
+
output: ListJobsOutputModel
|
|
74
|
+
},
|
|
75
|
+
policy: { auth: "user" },
|
|
76
|
+
acceptance: {
|
|
77
|
+
scenarios: [
|
|
78
|
+
{
|
|
79
|
+
key: "list-jobs-happy-path",
|
|
80
|
+
given: ["Jobs exist"],
|
|
81
|
+
when: ["User lists jobs"],
|
|
82
|
+
then: ["List of jobs is returned"]
|
|
83
|
+
}
|
|
84
|
+
],
|
|
85
|
+
examples: [
|
|
86
|
+
{
|
|
87
|
+
key: "list-active",
|
|
88
|
+
input: { status: "scheduled", limit: 10 },
|
|
89
|
+
output: { jobs: [], total: 5 }
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
var ScheduleJobContract = defineCommand({
|
|
95
|
+
meta: {
|
|
96
|
+
key: "service.job.schedule",
|
|
97
|
+
version: "1.0.0",
|
|
98
|
+
stability: "stable",
|
|
99
|
+
owners: [...OWNERS],
|
|
100
|
+
tags: ["service-business-os", "job", "schedule"],
|
|
101
|
+
description: "Schedule a job.",
|
|
102
|
+
goal: "Schedule work.",
|
|
103
|
+
context: "Job scheduling."
|
|
104
|
+
},
|
|
105
|
+
io: {
|
|
106
|
+
input: ScheduleJobInputModel,
|
|
107
|
+
output: JobModel
|
|
108
|
+
},
|
|
109
|
+
policy: { auth: "user" },
|
|
110
|
+
acceptance: {
|
|
111
|
+
scenarios: [
|
|
112
|
+
{
|
|
113
|
+
key: "schedule-job-happy-path",
|
|
114
|
+
given: ["Client exists"],
|
|
115
|
+
when: ["User schedules job"],
|
|
116
|
+
then: ["Job is created with status SCHEDULED"]
|
|
117
|
+
}
|
|
118
|
+
],
|
|
119
|
+
examples: [
|
|
120
|
+
{
|
|
121
|
+
key: "schedule-repair",
|
|
122
|
+
input: {
|
|
123
|
+
clientId: "client-123",
|
|
124
|
+
date: "2025-01-20T10:00:00Z",
|
|
125
|
+
type: "repair"
|
|
126
|
+
},
|
|
127
|
+
output: { id: "job-456", status: "scheduled" }
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
var CompleteJobContract = defineCommand({
|
|
133
|
+
meta: {
|
|
134
|
+
key: "service.job.complete",
|
|
135
|
+
version: "1.0.0",
|
|
136
|
+
stability: "stable",
|
|
137
|
+
owners: [...OWNERS],
|
|
138
|
+
tags: ["service-business-os", "job", "complete"],
|
|
139
|
+
description: "Mark a job as complete.",
|
|
140
|
+
goal: "Record job completion.",
|
|
141
|
+
context: "Job management."
|
|
142
|
+
},
|
|
143
|
+
io: {
|
|
144
|
+
input: CompleteJobInputModel,
|
|
145
|
+
output: JobModel
|
|
146
|
+
},
|
|
147
|
+
policy: { auth: "user" },
|
|
148
|
+
acceptance: {
|
|
149
|
+
scenarios: [
|
|
150
|
+
{
|
|
151
|
+
key: "complete-job-happy-path",
|
|
152
|
+
given: ["Job is scheduled"],
|
|
153
|
+
when: ["User completes job"],
|
|
154
|
+
then: ["Job status becomes COMPLETED"]
|
|
155
|
+
}
|
|
156
|
+
],
|
|
157
|
+
examples: [
|
|
158
|
+
{
|
|
159
|
+
key: "mark-complete",
|
|
160
|
+
input: { jobId: "job-456", notes: "Done successfully" },
|
|
161
|
+
output: { id: "job-456", status: "completed" }
|
|
162
|
+
}
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
export {
|
|
167
|
+
ScheduleJobInputModel,
|
|
168
|
+
ScheduleJobContract,
|
|
169
|
+
ListJobsOutputModel,
|
|
170
|
+
ListJobsOperation,
|
|
171
|
+
ListJobsInputModel,
|
|
172
|
+
JobModel,
|
|
173
|
+
CompleteJobInputModel,
|
|
174
|
+
CompleteJobContract
|
|
175
|
+
};
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
// src/job/job.schema.ts
|
|
2
|
+
import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
|
|
3
|
+
var JobModel = defineSchemaModel({
|
|
4
|
+
name: "Job",
|
|
5
|
+
description: "Scheduled job",
|
|
6
|
+
fields: {
|
|
7
|
+
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
8
|
+
quoteId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
9
|
+
clientId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
10
|
+
title: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
11
|
+
status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
12
|
+
scheduledAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
13
|
+
completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
14
|
+
assignedTo: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
var ScheduleJobInputModel = defineSchemaModel({
|
|
18
|
+
name: "ScheduleJobInput",
|
|
19
|
+
description: "Input for scheduling a job",
|
|
20
|
+
fields: {
|
|
21
|
+
quoteId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
22
|
+
scheduledAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
23
|
+
assignedTo: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
24
|
+
location: { type: ScalarTypeEnum.JSON(), isOptional: true },
|
|
25
|
+
title: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
var CompleteJobInputModel = defineSchemaModel({
|
|
29
|
+
name: "CompleteJobInput",
|
|
30
|
+
description: "Input for completing a job",
|
|
31
|
+
fields: {
|
|
32
|
+
jobId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
33
|
+
completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
34
|
+
notes: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// src/job/job.operations.ts
|
|
39
|
+
import { defineCommand, defineQuery } from "@contractspec/lib.contracts";
|
|
40
|
+
import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
|
|
41
|
+
var OWNERS = ["@examples.service-business-os"];
|
|
42
|
+
var ListJobsInputModel = defineSchemaModel2({
|
|
43
|
+
name: "ListJobsInput",
|
|
44
|
+
description: "Input for listing jobs",
|
|
45
|
+
fields: {
|
|
46
|
+
status: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
47
|
+
clientId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
48
|
+
limit: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
|
|
49
|
+
offset: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true }
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
var ListJobsOutputModel = defineSchemaModel2({
|
|
53
|
+
name: "ListJobsOutput",
|
|
54
|
+
description: "Output for listing jobs",
|
|
55
|
+
fields: {
|
|
56
|
+
jobs: { type: JobModel, isOptional: false, isList: true },
|
|
57
|
+
total: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false }
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
var ListJobsOperation = defineQuery({
|
|
61
|
+
meta: {
|
|
62
|
+
key: "service.job.list",
|
|
63
|
+
version: "1.0.0",
|
|
64
|
+
stability: "stable",
|
|
65
|
+
owners: [...OWNERS],
|
|
66
|
+
tags: ["service-business-os", "job", "list", "query"],
|
|
67
|
+
description: "List all jobs with filtering",
|
|
68
|
+
goal: "Retrieve list of jobs",
|
|
69
|
+
context: "Job management"
|
|
70
|
+
},
|
|
71
|
+
io: {
|
|
72
|
+
input: ListJobsInputModel,
|
|
73
|
+
output: ListJobsOutputModel
|
|
74
|
+
},
|
|
75
|
+
policy: { auth: "user" },
|
|
76
|
+
acceptance: {
|
|
77
|
+
scenarios: [
|
|
78
|
+
{
|
|
79
|
+
key: "list-jobs-happy-path",
|
|
80
|
+
given: ["Jobs exist"],
|
|
81
|
+
when: ["User lists jobs"],
|
|
82
|
+
then: ["List of jobs is returned"]
|
|
83
|
+
}
|
|
84
|
+
],
|
|
85
|
+
examples: [
|
|
86
|
+
{
|
|
87
|
+
key: "list-active",
|
|
88
|
+
input: { status: "scheduled", limit: 10 },
|
|
89
|
+
output: { jobs: [], total: 5 }
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
var ScheduleJobContract = defineCommand({
|
|
95
|
+
meta: {
|
|
96
|
+
key: "service.job.schedule",
|
|
97
|
+
version: "1.0.0",
|
|
98
|
+
stability: "stable",
|
|
99
|
+
owners: [...OWNERS],
|
|
100
|
+
tags: ["service-business-os", "job", "schedule"],
|
|
101
|
+
description: "Schedule a job.",
|
|
102
|
+
goal: "Schedule work.",
|
|
103
|
+
context: "Job scheduling."
|
|
104
|
+
},
|
|
105
|
+
io: {
|
|
106
|
+
input: ScheduleJobInputModel,
|
|
107
|
+
output: JobModel
|
|
108
|
+
},
|
|
109
|
+
policy: { auth: "user" },
|
|
110
|
+
acceptance: {
|
|
111
|
+
scenarios: [
|
|
112
|
+
{
|
|
113
|
+
key: "schedule-job-happy-path",
|
|
114
|
+
given: ["Client exists"],
|
|
115
|
+
when: ["User schedules job"],
|
|
116
|
+
then: ["Job is created with status SCHEDULED"]
|
|
117
|
+
}
|
|
118
|
+
],
|
|
119
|
+
examples: [
|
|
120
|
+
{
|
|
121
|
+
key: "schedule-repair",
|
|
122
|
+
input: {
|
|
123
|
+
clientId: "client-123",
|
|
124
|
+
date: "2025-01-20T10:00:00Z",
|
|
125
|
+
type: "repair"
|
|
126
|
+
},
|
|
127
|
+
output: { id: "job-456", status: "scheduled" }
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
var CompleteJobContract = defineCommand({
|
|
133
|
+
meta: {
|
|
134
|
+
key: "service.job.complete",
|
|
135
|
+
version: "1.0.0",
|
|
136
|
+
stability: "stable",
|
|
137
|
+
owners: [...OWNERS],
|
|
138
|
+
tags: ["service-business-os", "job", "complete"],
|
|
139
|
+
description: "Mark a job as complete.",
|
|
140
|
+
goal: "Record job completion.",
|
|
141
|
+
context: "Job management."
|
|
142
|
+
},
|
|
143
|
+
io: {
|
|
144
|
+
input: CompleteJobInputModel,
|
|
145
|
+
output: JobModel
|
|
146
|
+
},
|
|
147
|
+
policy: { auth: "user" },
|
|
148
|
+
acceptance: {
|
|
149
|
+
scenarios: [
|
|
150
|
+
{
|
|
151
|
+
key: "complete-job-happy-path",
|
|
152
|
+
given: ["Job is scheduled"],
|
|
153
|
+
when: ["User completes job"],
|
|
154
|
+
then: ["Job status becomes COMPLETED"]
|
|
155
|
+
}
|
|
156
|
+
],
|
|
157
|
+
examples: [
|
|
158
|
+
{
|
|
159
|
+
key: "mark-complete",
|
|
160
|
+
input: { jobId: "job-456", notes: "Done successfully" },
|
|
161
|
+
output: { id: "job-456", status: "completed" }
|
|
162
|
+
}
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
export {
|
|
167
|
+
ScheduleJobContract,
|
|
168
|
+
ListJobsOutputModel,
|
|
169
|
+
ListJobsOperation,
|
|
170
|
+
ListJobsInputModel,
|
|
171
|
+
CompleteJobContract
|
|
172
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// src/job/job.schema.ts
|
|
2
|
+
import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
|
|
3
|
+
var JobModel = defineSchemaModel({
|
|
4
|
+
name: "Job",
|
|
5
|
+
description: "Scheduled job",
|
|
6
|
+
fields: {
|
|
7
|
+
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
8
|
+
quoteId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
9
|
+
clientId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
10
|
+
title: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
11
|
+
status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
12
|
+
scheduledAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
13
|
+
completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
14
|
+
assignedTo: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
var ScheduleJobInputModel = defineSchemaModel({
|
|
18
|
+
name: "ScheduleJobInput",
|
|
19
|
+
description: "Input for scheduling a job",
|
|
20
|
+
fields: {
|
|
21
|
+
quoteId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
22
|
+
scheduledAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
23
|
+
assignedTo: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
24
|
+
location: { type: ScalarTypeEnum.JSON(), isOptional: true },
|
|
25
|
+
title: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
var CompleteJobInputModel = defineSchemaModel({
|
|
29
|
+
name: "CompleteJobInput",
|
|
30
|
+
description: "Input for completing a job",
|
|
31
|
+
fields: {
|
|
32
|
+
jobId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
33
|
+
completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
34
|
+
notes: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
export {
|
|
38
|
+
ScheduleJobInputModel,
|
|
39
|
+
JobModel,
|
|
40
|
+
CompleteJobInputModel
|
|
41
|
+
};
|