@ai0x0/utils 0.0.38 → 0.0.39

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.
Files changed (43) hide show
  1. package/.agents/skills/ai0x0-utils/backend/SKILL.md +12 -8
  2. package/SKILL.md +12 -8
  3. package/es/backend/route-operation/delete-operation.d.ts +3 -2
  4. package/es/backend/route-operation/delete-operation.js +35 -22
  5. package/es/backend/route-operation/get-list-operation.d.ts +6 -5
  6. package/es/backend/route-operation/get-list-operation.js +37 -22
  7. package/es/backend/route-operation/get-operation.d.ts +5 -4
  8. package/es/backend/route-operation/get-operation.js +34 -22
  9. package/es/backend/route-operation/post-operation.d.ts +5 -4
  10. package/es/backend/route-operation/post-operation.js +39 -34
  11. package/es/backend/route-operation/put-operation.d.ts +5 -4
  12. package/es/backend/route-operation/put-operation.js +44 -29
  13. package/es/backend/sqlite/route-operation/delete-operation.d.ts +2 -1
  14. package/es/backend/sqlite/route-operation/delete-operation.js +35 -25
  15. package/es/backend/sqlite/route-operation/get-list-operation.d.ts +2 -1
  16. package/es/backend/sqlite/route-operation/get-list-operation.js +37 -24
  17. package/es/backend/sqlite/route-operation/get-operation.d.ts +2 -1
  18. package/es/backend/sqlite/route-operation/get-operation.js +34 -24
  19. package/es/backend/sqlite/route-operation/post-operation.d.ts +2 -1
  20. package/es/backend/sqlite/route-operation/post-operation.js +39 -35
  21. package/es/backend/sqlite/route-operation/put-operation.d.ts +2 -1
  22. package/es/backend/sqlite/route-operation/put-operation.js +44 -32
  23. package/lib/backend/route-operation/delete-operation.d.ts +3 -2
  24. package/lib/backend/route-operation/delete-operation.js +5 -3
  25. package/lib/backend/route-operation/get-list-operation.d.ts +6 -5
  26. package/lib/backend/route-operation/get-list-operation.js +8 -8
  27. package/lib/backend/route-operation/get-operation.d.ts +5 -4
  28. package/lib/backend/route-operation/get-operation.js +8 -8
  29. package/lib/backend/route-operation/post-operation.d.ts +5 -4
  30. package/lib/backend/route-operation/post-operation.js +4 -3
  31. package/lib/backend/route-operation/put-operation.d.ts +5 -4
  32. package/lib/backend/route-operation/put-operation.js +6 -4
  33. package/lib/backend/sqlite/route-operation/delete-operation.d.ts +2 -1
  34. package/lib/backend/sqlite/route-operation/delete-operation.js +3 -2
  35. package/lib/backend/sqlite/route-operation/get-list-operation.d.ts +2 -1
  36. package/lib/backend/sqlite/route-operation/get-list-operation.js +8 -8
  37. package/lib/backend/sqlite/route-operation/get-operation.d.ts +2 -1
  38. package/lib/backend/sqlite/route-operation/get-operation.js +8 -8
  39. package/lib/backend/sqlite/route-operation/post-operation.d.ts +2 -1
  40. package/lib/backend/sqlite/route-operation/post-operation.js +4 -3
  41. package/lib/backend/sqlite/route-operation/put-operation.d.ts +2 -1
  42. package/lib/backend/sqlite/route-operation/put-operation.js +4 -3
  43. package/package.json +1 -1
@@ -44,6 +44,7 @@ var createGetListOperation = ({
44
44
  bodySchema,
45
45
  table,
46
46
  summary,
47
+ tags,
47
48
  relations,
48
49
  jsonArrayFields,
49
50
  setParams,
@@ -54,7 +55,7 @@ var createGetListOperation = ({
54
55
  method: "GET",
55
56
  openApiOperation: {
56
57
  summary,
57
- tags: [(0, import_get_table_name.default)(table)]
58
+ tags: tags ?? (table ? [(0, import_get_table_name.default)(table)] : [])
58
59
  }
59
60
  }).input({
60
61
  query: querySchema
@@ -73,18 +74,17 @@ var createGetListOperation = ({
73
74
  const { userId } = await getSession(req) || {};
74
75
  params.creatorId = userId;
75
76
  }
76
- let result = await (0, import_actions.createGetListAction)({
77
+ const mergedParams = Object.assign(
78
+ Object.fromEntries(new URL(req.url).searchParams),
79
+ params
80
+ );
81
+ let result = table ? await (0, import_actions.createGetListAction)({
77
82
  bodySchema,
78
83
  db,
79
84
  jsonArrayFields,
80
85
  relations,
81
86
  table
82
- })(
83
- Object.assign(
84
- Object.fromEntries(new URL(req.url).searchParams),
85
- params
86
- )
87
- );
87
+ })(mergedParams) : { data: [], total: 0 };
88
88
  if (onSuccess) {
89
89
  result = await onSuccess(result);
90
90
  }
@@ -10,7 +10,8 @@ export interface GetOperationOptions<T extends ZodSchema, Q extends ZodSchema, T
10
10
  onSuccess?: (_data: z.infer<T>) => Promise<z.infer<T>>;
11
11
  onError?: (_error: Error) => Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
12
12
  summary?: string;
13
- table: TTable;
13
+ tags?: string[];
14
+ table?: TTable;
14
15
  byCreator?: boolean;
15
16
  }
16
17
  export declare const createGetOperation: any;
@@ -43,6 +43,7 @@ var createGetOperation = ({
43
43
  bodySchema,
44
44
  table,
45
45
  summary,
46
+ tags,
46
47
  relations,
47
48
  setParams,
48
49
  jsonArrayFields,
@@ -53,7 +54,7 @@ var createGetOperation = ({
53
54
  method: "GET",
54
55
  openApiOperation: {
55
56
  summary,
56
- tags: [(0, import_get_table_name.default)(table)]
57
+ tags: tags ?? (table ? [(0, import_get_table_name.default)(table)] : [])
57
58
  }
58
59
  }).input({
59
60
  query: querySchema
@@ -72,18 +73,17 @@ var createGetOperation = ({
72
73
  const { userId } = await getSession(req) || {};
73
74
  params.creatorId = userId;
74
75
  }
75
- const rawResult = await (0, import_actions.createGetAction)({
76
+ const mergedParams = Object.assign(
77
+ Object.fromEntries(new URL(req.url).searchParams),
78
+ params
79
+ );
80
+ const rawResult = table ? await (0, import_actions.createGetAction)({
76
81
  bodySchema,
77
82
  db,
78
83
  jsonArrayFields,
79
84
  relations,
80
85
  table
81
- })(
82
- Object.assign(
83
- Object.fromEntries(new URL(req.url).searchParams),
84
- params
85
- )
86
- );
86
+ })(mergedParams) : mergedParams;
87
87
  let result = rawResult ?? {};
88
88
  if (onSuccess) {
89
89
  result = await onSuccess(result);
@@ -6,8 +6,9 @@ export interface PostOperationOptions<IB extends ZodSchema, OB extends ZodSchema
6
6
  outputBodySchema?: IB;
7
7
  setBody?: (_req: TypedNextRequest<"POST", "application/json", z.infer<IB>>) => Promise<Partial<z.infer<IB>>>;
8
8
  summary?: string;
9
+ tags?: string[];
9
10
  onSuccess?: (_data: z.infer<OB>) => Promise<z.infer<OB>>;
10
11
  onError?: (_error: Error) => Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
11
- table: TTable;
12
+ table?: TTable;
12
13
  }
13
14
  export declare const createPostOperation: any;
@@ -44,6 +44,7 @@ var createPostOperation = ({
44
44
  outputBodySchema,
45
45
  setBody,
46
46
  summary,
47
+ tags,
47
48
  table,
48
49
  onSuccess,
49
50
  onError
@@ -51,7 +52,7 @@ var createPostOperation = ({
51
52
  method: "POST",
52
53
  openApiOperation: {
53
54
  summary,
54
- tags: [(0, import_get_table_name.default)(table)]
55
+ tags: tags ?? (table ? [(0, import_get_table_name.default)(table)] : [])
55
56
  }
56
57
  }).input({
57
58
  body: bodySchema,
@@ -70,10 +71,10 @@ var createPostOperation = ({
70
71
  req
71
72
  )) || {};
72
73
  const mergedBody = { ...body, ...extraBody };
73
- const [raw] = await (0, import_actions.createPostAction)({ bodySchema, db, table })({
74
+ const raw = table ? (await (0, import_actions.createPostAction)({ bodySchema, db, table })({
74
75
  creatorId: userId,
75
76
  ...mergedBody
76
- });
77
+ }))[0] : { creatorId: userId, ...mergedBody };
77
78
  const data = onSuccess ? await onSuccess(raw) : raw;
78
79
  return import_next_rest_framework.TypedNextResponse.json(data, {
79
80
  status: 200
@@ -4,8 +4,9 @@ import { TypedNextRequest, TypedNextResponse } from "next-rest-framework";
4
4
  export interface PutOperationOptions<IB extends ZodSchema, OB extends ZodSchema, TTable extends SQLiteTable> {
5
5
  bodySchema: IB;
6
6
  outputBodySchema?: OB;
7
- table: TTable;
7
+ table?: TTable;
8
8
  summary?: string;
9
+ tags?: string[];
9
10
  setBody?: (_req: TypedNextRequest<"PUT", "application/json", z.infer<IB>>) => Promise<Partial<z.infer<IB>>>;
10
11
  onSuccess?: (_data: z.infer<OB>) => Promise<z.infer<OB>>;
11
12
  onError?: (_error: Error) => Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
@@ -45,6 +45,7 @@ var createPutOperation = ({
45
45
  outputBodySchema,
46
46
  table,
47
47
  summary,
48
+ tags,
48
49
  setBody,
49
50
  onSuccess,
50
51
  byCreator = true,
@@ -53,7 +54,7 @@ var createPutOperation = ({
53
54
  method: "PUT",
54
55
  openApiOperation: {
55
56
  summary,
56
- tags: [(0, import_get_table_name.default)(table)]
57
+ tags: tags ?? (table ? [(0, import_get_table_name.default)(table)] : [])
57
58
  }
58
59
  }).input({
59
60
  body: bodySchema,
@@ -72,11 +73,11 @@ var createPutOperation = ({
72
73
  req
73
74
  )) || {};
74
75
  const mergedBody = { ...body, ...extraBody };
75
- const raw = await (0, import_actions.createPutAction)({
76
+ const raw = table ? await (0, import_actions.createPutAction)({
76
77
  bodySchema,
77
78
  table,
78
79
  db
79
- })({ editorId: userId, ...mergedBody }, { byCreator });
80
+ })({ editorId: userId, ...mergedBody }, { byCreator }) : { editorId: userId, ...mergedBody };
80
81
  const data = onSuccess ? await onSuccess(raw) : raw;
81
82
  return import_next_rest_framework.TypedNextResponse.json(data, {
82
83
  status: 200
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai0x0/utils",
3
- "version": "0.0.38",
3
+ "version": "0.0.39",
4
4
  "description": "AI0x0 utils",
5
5
  "keywords": [
6
6
  "ai0x0"