@wzyjs/next 0.3.18 → 0.3.20

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.
@@ -60,17 +60,17 @@ export const useHabitGroupCRUD = <TList extends FindManyArgs = FindManyArgs, TIn
60
60
  const listState = api.habitGroup.findMany.useQuery(list === false ? undefined : list?.query, {
61
61
  enabled: list !== false,
62
62
  ...(list ? list.option : undefined),
63
- })
63
+ } as any)
64
64
 
65
65
  const countState = api.habitGroup.count.useQuery(list === false ? {} as any : r(list?.query), {
66
66
  enabled: list !== false,
67
67
  ...(list ? list.option : undefined),
68
- })
68
+ } as any)
69
69
 
70
70
  const infoState = api.habitGroup.findUnique.useQuery(info?.query || {} as any, {
71
71
  enabled: !!info,
72
72
  ...(info ? info.option : undefined),
73
- })
73
+ } as any)
74
74
 
75
75
  const tagsConfig: Option['tags'] | false = tags
76
76
  const tagsEnabled: boolean = Boolean(tagsConfig)
@@ -81,7 +81,7 @@ export const useHabitGroupCRUD = <TList extends FindManyArgs = FindManyArgs, TIn
81
81
  const tagsState = api.habitGroup.getAllTags.useQuery(tagsQuery as any, {
82
82
  enabled: tagsEnabled,
83
83
  ...(tagsConfig && typeof tagsConfig === 'object' ? tagsConfig.option : undefined),
84
- })
84
+ } as any)
85
85
 
86
86
  const onSuccess = (tip: string) => {
87
87
  message.destroy()
@@ -42,29 +42,26 @@ var path = require("node:path");
42
42
  var generateTags = function (model, outputPath) { return __awaiter(void 0, void 0, void 0, function () {
43
43
  var modelsWithTags, _i, modelsWithTags_1, dataModel, modelName, routerFilePath, fileContent, delegateName, getAllTagsInterface, lastCommaIndex, closingBraceIndex, beforeInsertion, afterInsertion, newContent;
44
44
  return __generator(this, function (_a) {
45
- modelsWithTags = model.declarations.filter(function (item) { return item.$type === 'DataModel'; });
46
- // .filter(dataModel => {
47
- // return dataModel.fields.some(field => field.name === 'tags')
48
- // })
45
+ modelsWithTags = model.declarations.filter(function (item) {
46
+ if (item.$type !== 'DataModel') return false;
47
+ return item.fields.some(function (field) { return field.name === 'tags'; });
48
+ });
49
49
  if (modelsWithTags.length === 0) {
50
50
  return [2 /*return*/];
51
51
  }
52
- // 为每个有 tags 字段的模型添加 getAllTags 接口
53
52
  for (_i = 0, modelsWithTags_1 = modelsWithTags; _i < modelsWithTags_1.length; _i++) {
54
53
  dataModel = modelsWithTags_1[_i];
55
54
  modelName = String(dataModel.name);
56
55
  routerFilePath = path.join(outputPath, 'trpc', 'routers', "".concat(modelName, ".router.ts"));
57
- // 检查文件是否存在
58
56
  if (!fs.existsSync(routerFilePath)) {
59
57
  continue;
60
58
  }
61
59
  fileContent = fs.readFileSync(routerFilePath, 'utf-8');
62
- // 检查是否已经添加了 getAllTags 接口
63
60
  if (fileContent.includes('getAllTags:')) {
64
61
  continue;
65
62
  }
66
63
  delegateName = modelName.charAt(0).toLowerCase() + modelName.slice(1);
67
- getAllTagsInterface = "\n getAllTags: procedure\n .query(async ({ ctx, input }) => {\n const records = await checkRead(db(ctx).".concat(delegateName, ".findMany({\n ...(input?.where ? { where: input.where } : {}),\n select: { tags: true },\n }))\n\n // \u6241\u5E73\u5316 + \u53BB\u91CD\n const uniqueTags = Array.from(new Set(records.flatMap(record => record.tags || [])))\n\n return uniqueTags\n }),");
64
+ getAllTagsInterface = "\n getAllTags: procedure\n .query(async ({ ctx, input }) => {\n const records = await checkRead(db(ctx)." + delegateName + ".findMany({\n ...(input?.where ? { where: input.where } : {}),\n select: { tags: true },\n }))\n\n // \u6241\u5E73\u5316 + \u53BB\u91CD\n const uniqueTags = Array.from(new Set(records.flatMap(record => record.tags || [])))\n\n return uniqueTags\n }),";
68
65
  lastCommaIndex = fileContent.lastIndexOf(',');
69
66
  closingBraceIndex = fileContent.indexOf('\n }\n );', lastCommaIndex);
70
67
  if (closingBraceIndex === -1) {
@@ -74,11 +71,10 @@ var generateTags = function (model, outputPath) { return __awaiter(void 0, void
74
71
  beforeInsertion = fileContent.substring(0, closingBraceIndex);
75
72
  afterInsertion = fileContent.substring(closingBraceIndex);
76
73
  newContent = beforeInsertion + getAllTagsInterface + afterInsertion;
77
- // 写入文件
78
74
  fs.writeFileSync(routerFilePath, newContent, 'utf-8');
79
75
  }
80
76
  console.log("\u2705 Tags \u529F\u80FD\u751F\u6210\u5B8C\u6210\uFF0C\u5171\u5904\u7406 ".concat(modelsWithTags.length, " \u4E2A\u5305\u542B tags \u5B57\u6BB5\u7684\u6A21\u578B"));
81
77
  return [2 /*return*/];
82
78
  });
83
79
  }); };
84
- exports.generateTags = generateTags;
80
+ exports.generateTags = generateTags;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wzyjs/next",
3
- "version": "0.3.18",
3
+ "version": "0.3.20",
4
4
  "description": "description",
5
5
  "author": "wzy",
6
6
  "main": "dist/index.js",
@@ -17,7 +17,7 @@
17
17
  "dependencies": {
18
18
  "@zenstackhq/sdk": "^2.12.3"
19
19
  },
20
- "gitHead": "10e941a36df74182a45c73e7e074fc0c5ed5b669",
20
+ "gitHead": "75ecd6752ea11d3e5d51ef76cd4393dca75c358b",
21
21
  "publishConfig": {
22
22
  "access": "public"
23
23
  }