@lokalise/maestro-nextgen-tenant-lib 1.1.0 → 1.2.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.
@@ -0,0 +1,10 @@
1
+ import { z } from 'zod/v4';
2
+ export declare const TASK: z.ZodObject<{
3
+ id: z.ZodGUID;
4
+ }, z.core.$strip>;
5
+ export declare const TASK_TYPE: z.ZodEnum<{
6
+ review: "review";
7
+ }>;
8
+ export declare const TASK_ACTOR: z.ZodEnum<{
9
+ human: "human";
10
+ }>;
package/dist/common.js ADDED
@@ -0,0 +1,8 @@
1
+ import { z } from 'zod/v4';
2
+ export const TASK = z.object({
3
+ id: z.guid(),
4
+ // TODO: extend with actual task schema in https://lokalise.atlassian.net/browse/MET-996
5
+ });
6
+ export const TASK_TYPE = z.enum(['review']).describe('Type of the task');
7
+ export const TASK_ACTOR = z.enum(['human']).describe('Actor responsible for the task');
8
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE1B,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE;IACZ,wFAAwF;CACzF,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAA;AACxE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,gCAAgC,CAAC,CAAA"}
@@ -0,0 +1,154 @@
1
+ import { type ConsumerMessageSchema, type PublisherMessageSchema } from '@message-queue-toolkit/schemas';
2
+ import { z } from 'zod/v4';
3
+ export declare const MAESTRO_TASK_TOPIC = "maestro-task";
4
+ /**
5
+ * Payload schemas
6
+ */
7
+ export declare const TASK_CREATED_EVENT_PAYLOAD_SCHEMA: z.ZodObject<{
8
+ task: z.ZodObject<{
9
+ id: z.ZodGUID;
10
+ }, z.core.$strip>;
11
+ }, z.core.$strip>;
12
+ export declare const TASK_ACTION_CREATE_TASK_EVENT_PAYLOAD_SCHEMA: z.ZodObject<{
13
+ tenant: z.ZodEnum<{
14
+ expert: "expert";
15
+ nextgen: "nextgen";
16
+ }>;
17
+ ownerId: z.ZodGUID;
18
+ projectId: z.ZodGUID;
19
+ projectName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
20
+ itemId: z.ZodOptional<z.ZodNullable<z.ZodGUID>>;
21
+ type: z.ZodEnum<{
22
+ review: "review";
23
+ }>;
24
+ actor: z.ZodEnum<{
25
+ human: "human";
26
+ }>;
27
+ sourceLanguageId: z.ZodGUID;
28
+ taskAssignments: z.ZodArray<z.ZodObject<{
29
+ languageId: z.ZodGUID;
30
+ userIds: z.ZodOptional<z.ZodArray<z.ZodGUID>>;
31
+ userGroupIds: z.ZodOptional<z.ZodArray<z.ZodGUID>>;
32
+ unitIds: z.ZodArray<z.ZodGUID>;
33
+ }, z.core.$strip>>;
34
+ dueDate: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
35
+ }, z.core.$strip>;
36
+ /**
37
+ * Event definitions
38
+ */
39
+ export declare const TaskEvents: {
40
+ 'task.created': {
41
+ snsTopic: string;
42
+ producedBy: string[];
43
+ consumerSchema: z.ZodObject<{
44
+ id: z.ZodString;
45
+ timestamp: z.ZodISODateTime;
46
+ type: z.ZodLiteral<"task.created">;
47
+ deduplicationId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
48
+ deduplicationOptions: z.ZodOptional<z.ZodNullable<typeof import("@message-queue-toolkit/schemas").MESSAGE_DEDUPLICATION_OPTIONS_SCHEMA>>;
49
+ payload: z.ZodObject<{
50
+ task: z.ZodObject<{
51
+ id: z.ZodGUID;
52
+ }, z.core.$strip>;
53
+ }, z.core.$strip>;
54
+ metadata: import("@message-queue-toolkit/schemas").MetadataObject;
55
+ }, z.core.$strip>;
56
+ publisherSchema: z.ZodObject<{
57
+ id: z.ZodOptional<z.ZodString>;
58
+ timestamp: z.ZodOptional<z.ZodISODateTime>;
59
+ type: z.ZodLiteral<"task.created">;
60
+ deduplicationId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
61
+ deduplicationOptions: z.ZodOptional<z.ZodNullable<typeof import("@message-queue-toolkit/schemas").MESSAGE_DEDUPLICATION_OPTIONS_SCHEMA>>;
62
+ payload: z.ZodObject<{
63
+ task: z.ZodObject<{
64
+ id: z.ZodGUID;
65
+ }, z.core.$strip>;
66
+ }, z.core.$strip>;
67
+ metadata: z.ZodOptional<z.ZodObject<{
68
+ schemaVersion: z.ZodOptional<z.ZodString>;
69
+ producedBy: z.ZodOptional<z.ZodString>;
70
+ originatedFrom: z.ZodOptional<z.ZodString>;
71
+ correlationId: z.ZodOptional<z.ZodString>;
72
+ }>>;
73
+ }, z.core.$strip>;
74
+ };
75
+ 'task.action.create_task': {
76
+ producedBy: string[];
77
+ consumerSchema: z.ZodObject<{
78
+ id: z.ZodString;
79
+ timestamp: z.ZodISODateTime;
80
+ type: z.ZodLiteral<"task.action.create_task">;
81
+ deduplicationId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
82
+ deduplicationOptions: z.ZodOptional<z.ZodNullable<typeof import("@message-queue-toolkit/schemas").MESSAGE_DEDUPLICATION_OPTIONS_SCHEMA>>;
83
+ payload: z.ZodObject<{
84
+ tenant: z.ZodEnum<{
85
+ expert: "expert";
86
+ nextgen: "nextgen";
87
+ }>;
88
+ ownerId: z.ZodGUID;
89
+ projectId: z.ZodGUID;
90
+ projectName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
91
+ itemId: z.ZodOptional<z.ZodNullable<z.ZodGUID>>;
92
+ type: z.ZodEnum<{
93
+ review: "review";
94
+ }>;
95
+ actor: z.ZodEnum<{
96
+ human: "human";
97
+ }>;
98
+ sourceLanguageId: z.ZodGUID;
99
+ taskAssignments: z.ZodArray<z.ZodObject<{
100
+ languageId: z.ZodGUID;
101
+ userIds: z.ZodOptional<z.ZodArray<z.ZodGUID>>;
102
+ userGroupIds: z.ZodOptional<z.ZodArray<z.ZodGUID>>;
103
+ unitIds: z.ZodArray<z.ZodGUID>;
104
+ }, z.core.$strip>>;
105
+ dueDate: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
106
+ }, z.core.$strip>;
107
+ metadata: import("@message-queue-toolkit/schemas").MetadataObject;
108
+ }, z.core.$strip>;
109
+ publisherSchema: z.ZodObject<{
110
+ id: z.ZodOptional<z.ZodString>;
111
+ timestamp: z.ZodOptional<z.ZodISODateTime>;
112
+ type: z.ZodLiteral<"task.action.create_task">;
113
+ deduplicationId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
114
+ deduplicationOptions: z.ZodOptional<z.ZodNullable<typeof import("@message-queue-toolkit/schemas").MESSAGE_DEDUPLICATION_OPTIONS_SCHEMA>>;
115
+ payload: z.ZodObject<{
116
+ tenant: z.ZodEnum<{
117
+ expert: "expert";
118
+ nextgen: "nextgen";
119
+ }>;
120
+ ownerId: z.ZodGUID;
121
+ projectId: z.ZodGUID;
122
+ projectName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
123
+ itemId: z.ZodOptional<z.ZodNullable<z.ZodGUID>>;
124
+ type: z.ZodEnum<{
125
+ review: "review";
126
+ }>;
127
+ actor: z.ZodEnum<{
128
+ human: "human";
129
+ }>;
130
+ sourceLanguageId: z.ZodGUID;
131
+ taskAssignments: z.ZodArray<z.ZodObject<{
132
+ languageId: z.ZodGUID;
133
+ userIds: z.ZodOptional<z.ZodArray<z.ZodGUID>>;
134
+ userGroupIds: z.ZodOptional<z.ZodArray<z.ZodGUID>>;
135
+ unitIds: z.ZodArray<z.ZodGUID>;
136
+ }, z.core.$strip>>;
137
+ dueDate: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
138
+ }, z.core.$strip>;
139
+ metadata: z.ZodOptional<z.ZodObject<{
140
+ schemaVersion: z.ZodOptional<z.ZodString>;
141
+ producedBy: z.ZodOptional<z.ZodString>;
142
+ originatedFrom: z.ZodOptional<z.ZodString>;
143
+ correlationId: z.ZodOptional<z.ZodString>;
144
+ }>>;
145
+ }, z.core.$strip>;
146
+ };
147
+ };
148
+ /**
149
+ * Event types
150
+ */
151
+ export type TaskCreatedConsumerEvent = ConsumerMessageSchema<(typeof TaskEvents)['task.created']>;
152
+ export type TaskCreatedPublisherEvent = PublisherMessageSchema<(typeof TaskEvents)['task.created']>;
153
+ export type TaskActionCreateTaskConsumerEvent = ConsumerMessageSchema<(typeof TaskEvents)['task.action.create_task']>;
154
+ export type TaskActionCreateTaskPublisherEvent = PublisherMessageSchema<(typeof TaskEvents)['task.action.create_task']>;
@@ -0,0 +1,74 @@
1
+ import { TENANT } from '@lokalise/maestro-common';
2
+ import { enrichMessageSchemaWithBase, } from '@message-queue-toolkit/schemas';
3
+ import { z } from 'zod/v4';
4
+ import { TASK, TASK_ACTOR, TASK_TYPE } from '../common.js';
5
+ export const MAESTRO_TASK_TOPIC = 'maestro-task';
6
+ /**
7
+ * Payload schemas
8
+ */
9
+ export const TASK_CREATED_EVENT_PAYLOAD_SCHEMA = z.object({
10
+ task: TASK.describe('Task that was created'),
11
+ });
12
+ const TASK_ASSIGNMENT_SCHEMA = z
13
+ .object({
14
+ languageId: z.guid().describe('Language of the assignment'),
15
+ userIds: z
16
+ .optional(z.array(z.guid()).nonempty())
17
+ .describe('User IDs to assign to the assignment'),
18
+ userGroupIds: z
19
+ .optional(z.array(z.guid()).nonempty())
20
+ .describe('User group IDs to assign to the assignment'),
21
+ unitIds: z
22
+ .array(z.guid())
23
+ .nonempty({ message: 'unitIds must contain at least 1 item' })
24
+ .describe('List of translation/segment IDs to include in the assignment'),
25
+ })
26
+ .refine((assignment) => (assignment.userIds && assignment.userIds.length > 0) ||
27
+ (assignment.userGroupIds && assignment.userGroupIds.length > 0), { message: 'At least one of userIds or userGroupIds must be provided', path: ['userIds'] })
28
+ .describe('Sub-task that targets one and only one language');
29
+ export const TASK_ACTION_CREATE_TASK_EVENT_PAYLOAD_SCHEMA = z
30
+ .object({
31
+ tenant: TENANT.describe('Tenant that is commanding task creation'),
32
+ ownerId: z.guid().describe('ID of the owner that is commanding task creation'),
33
+ projectId: z.guid().describe('ID of the project where the task is to be created'),
34
+ projectName: z
35
+ .string()
36
+ .trim()
37
+ .min(1)
38
+ .max(256)
39
+ .nullish()
40
+ .describe('Name of the project where the task is to be created'),
41
+ itemId: z
42
+ .guid()
43
+ .nullish()
44
+ .describe('ID of the item to which the task is related, e.g. file ID'),
45
+ type: TASK_TYPE,
46
+ actor: TASK_ACTOR,
47
+ sourceLanguageId: z.guid().describe('Source language of the task'),
48
+ taskAssignments: z
49
+ .array(TASK_ASSIGNMENT_SCHEMA)
50
+ .nonempty({ message: 'taskAssignments must contain at least 1 item' })
51
+ .describe('List of task assignments, each targeting one different language'),
52
+ dueDate: z.iso.datetime().nullish().describe('Due date of the task'),
53
+ })
54
+ .refine((payload) => new Set(payload.taskAssignments.map((assignment) => assignment.languageId)).size ===
55
+ payload.taskAssignments.length, { message: 'languageId must be unique across taskAssignments', path: ['taskAssignments'] });
56
+ /**
57
+ * Event definitions
58
+ */
59
+ export const TaskEvents = {
60
+ 'task.created': {
61
+ ...enrichMessageSchemaWithBase('task.created', TASK_CREATED_EVENT_PAYLOAD_SCHEMA, {
62
+ description: 'Indicates that a task was created',
63
+ }),
64
+ snsTopic: MAESTRO_TASK_TOPIC,
65
+ producedBy: ['maestro'],
66
+ },
67
+ 'task.action.create_task': {
68
+ ...enrichMessageSchemaWithBase('task.action.create_task', TASK_ACTION_CREATE_TASK_EVENT_PAYLOAD_SCHEMA, {
69
+ description: 'Commands to create a task',
70
+ }),
71
+ producedBy: ['backend-translation-storage'],
72
+ },
73
+ };
74
+ //# sourceMappingURL=task.js.map
@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CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI;IAChF,OAAO,CAAC,eAAe,CAAC,MAAM,EAChC,EAAE,OAAO,EAAE,kDAAkD,EAAE,IAAI,EAAE,CAAC,iBAAiB,CAAC,EAAE,CAC3F,CAAA;AAEH;;GAEG;AAEH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,cAAc,EAAE;QACd,GAAG,2BAA2B,CAAC,cAAc,EAAE,iCAAiC,EAAE;YAChF,WAAW,EAAE,mCAAmC;SACjD,CAAC;QACF,QAAQ,EAAE,kBAAkB;QAC5B,UAAU,EAAE,CAAC,SAAS,CAAC;KACxB;IACD,yBAAyB,EAAE;QACzB,GAAG,2BAA2B,CAC5B,yBAAyB,EACzB,4CAA4C,EAC5C;YACE,WAAW,EAAE,2BAA2B;SACzC,CACF;QACD,UAAU,EAAE,CAAC,6BAA6B,CAAC;KAC5C;CACgD,CAAA"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './apiContract/schemas.js';
2
2
  export * from './apiContract/taskContracts.js';
3
- export * from './event-schemas/tasks.js';
3
+ export * from './common.js';
4
+ export * from './event-schemas/task.js';
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './apiContract/schemas.js';
2
2
  export * from './apiContract/taskContracts.js';
3
- export * from './event-schemas/tasks.js';
3
+ export * from './common.js';
4
+ export * from './event-schemas/task.js';
4
5
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,0BAA0B,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,aAAa,CAAA;AAC3B,cAAc,yBAAyB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lokalise/maestro-nextgen-tenant-lib",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "license": "Apache-2.0",
5
5
  "homepage": "https://github.com/lokalise/maestro",
6
6
  "description": "This library provides objects, types and zod schemas for NextGen tenant to work with Maestro",
@@ -37,6 +37,9 @@
37
37
  "engines": {
38
38
  "node": ">=20.12.2"
39
39
  },
40
+ "dependencies": {
41
+ "@message-queue-toolkit/schemas": "^7.1.0"
42
+ },
40
43
  "peerDependencies": {
41
44
  "@lokalise/maestro-common": "^5.0.0",
42
45
  "zod": ">=3.25.76"
@@ -1,4 +0,0 @@
1
- import { z } from 'zod/v4';
2
- export declare const TASK_CREATED_EVENT_PAYLOAD_SCHEMA: z.ZodObject<{
3
- taskId: z.ZodGUID;
4
- }, z.core.$strip>;
@@ -1,5 +0,0 @@
1
- import { z } from 'zod/v4';
2
- export const TASK_CREATED_EVENT_PAYLOAD_SCHEMA = z.object({
3
- taskId: z.guid(),
4
- }); // TODO: this is just to set up the lib, should be extended in https://lokalise.atlassian.net/browse/MET-993
5
- //# sourceMappingURL=tasks.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tasks.js","sourceRoot":"","sources":["../../src/event-schemas/tasks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE1B,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,CAAC,MAAM,CAAC;IACxD,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE;CACjB,CAAC,CAAA,CAAC,4GAA4G"}