@simitgroup/simpleapp-generator 1.6.7-h-alpha → 1.6.7-j-alpha

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 (37) hide show
  1. package/ReleaseNote.md +12 -0
  2. package/dist/generate.js +2 -0
  3. package/dist/generate.js.map +1 -1
  4. package/package.json +1 -1
  5. package/src/generate.ts +2 -0
  6. package/templates/basic/miniApi/resource.controller.ts.eta +122 -52
  7. package/templates/basic/miniApi/resource.service.ts.eta +61 -25
  8. package/templates/basic/nest/apischema.ts.eta +21 -6
  9. package/templates/basic/nest/controller.ts.eta +37 -16
  10. package/templates/basic/nuxt/resource-bridge.service.ts.eta +3 -2
  11. package/templates/miniApi/src/constants/api-scopes.ts.eta +22 -4
  12. package/templates/miniApi/src/constants/available-custom-field.ts.eta +22 -0
  13. package/templates/nest/src/simpleapp/generate/commons/middlewares/tenant.middleware.ts.eta +34 -14
  14. package/templates/nest/src/simpleapp/generate/commons/robotuser.service.ts.eta +4 -8
  15. package/templates/nest/src/simpleapp/generate/commons/user.context.ts.eta +154 -17
  16. package/templates/nest/src/simpleapp/generate/processors/simpleapp.processor.ts.eta +125 -441
  17. package/templates/nuxt/composables/getUserStore.generate.ts.eta +62 -66
  18. package/templates/nuxt/plugins/19.simpleapp-mini-app-store.ts.eta +240 -203
  19. package/templates/nuxt/plugins/20.simpleapp-userstore.ts.eta +1 -1
  20. package/templates/nuxt/simpleapp/generate/features/miniApp/app/components/MiniAppFeatureCustomField.vue.eta +34 -0
  21. package/templates/nuxt/simpleapp/generate/features/miniApp/app/components/MiniAppFeatureCustomPage.vue.eta +68 -0
  22. package/templates/nuxt/simpleapp/generate/features/miniApp/app/components/MiniAppFeatureScope.vue.eta +53 -0
  23. package/templates/nuxt/simpleapp/generate/features/miniApp/app/components/MiniAppIcon.vue.eta +49 -0
  24. package/templates/nuxt/simpleapp/generate/features/miniApp/app/components/MiniAppMenuButton.vue.eta +6 -4
  25. package/templates/nuxt/simpleapp/generate/features/miniApp/app/components/MiniAppPageIframe.vue.eta +9 -3
  26. package/templates/nuxt/simpleapp/generate/features/miniApp/app/components/MiniAppPermissionWrapper.vue.eta +4 -4
  27. package/templates/nuxt/simpleapp/generate/features/miniApp/app/components/MiniAppRestrictedWarning.vue.eta +3 -3
  28. package/templates/nuxt/simpleapp/generate/features/miniApp/app/components/MiniAppSettingLayout.vue.eta +3 -3
  29. package/templates/nuxt/simpleapp/generate/features/miniApp/app/components/MiniAppSettingPage.vue.eta +2 -2
  30. package/templates/nuxt/simpleapp/generate/features/miniApp/app/components/MiniAppWrapper.vue.eta +2 -32
  31. package/templates/nuxt/simpleapp/generate/features/miniApp/app/components/integration/MiniAppIntegrationItem.vue.eta +6 -5
  32. package/templates/nuxt/simpleapp/generate/features/miniApp/app/components/integration/MiniAppIntegrationItemBadge.vue.eta +15 -9
  33. package/templates/nuxt/simpleapp/generate/features/miniApp/app/components/integration/MiniAppIntegrationItemGroup.vue.eta +4 -4
  34. package/templates/nuxt/simpleapp/generate/features/miniApp/app/components/integration/MiniAppIntegrationPage.vue.eta +135 -22
  35. package/templates/nuxt/simpleapp/generate/features/miniApp/app/types/miniApp.ts.eta +7 -7
  36. package/templates/nuxt/simpleapp/generate/features/miniApp/bridge/services/bridge-resource-accessor.service.ts.eta +3 -1
  37. package/templates/nuxt/simpleapp/generate/features/miniApp/bridge/services/bridge.service.ts.eta +3 -0
@@ -0,0 +1,34 @@
1
+ <template>
2
+ <div
3
+ v-if="miniApp.integration.enabled.customField"
4
+ class="flex flex-col gap-2"
5
+ >
6
+ <div
7
+ v-for="field in miniApp.integration.customField?.fields"
8
+ class="flex gap-2 bg-slate-100 rounded-xl px-4 py-3"
9
+ >
10
+ <div>
11
+ <div class="flex items-center gap-2 font-semibold text-surface-700">
12
+ <span
13
+ class="text-xs bg-primary-100 text-primary-500 px-4 py-1 rounded-md"
14
+ >{{ t(`${field.code}`) }}
15
+ </span>
16
+ <span>
17
+ {{ field.title }}
18
+ </span>
19
+ </div>
20
+
21
+ <div class="text-surface-400 text-sm mt-1">
22
+ {{ field.description }}
23
+ </div>
24
+ </div>
25
+ </div>
26
+ </div>
27
+ </template>
28
+ <script setup lang="ts">
29
+ import { MiniAppDetail } from "~/simpleapp/generate/openapi";
30
+
31
+ const props = defineProps<{
32
+ miniApp: MiniAppDetail;
33
+ }>();
34
+ </script>
@@ -0,0 +1,68 @@
1
+ <template>
2
+ <Tabs value="pages">
3
+ <TabList>
4
+ <Tab value="pages">
5
+ {{ t("pages") }}
6
+ </Tab>
7
+ <Tab value="scopes">
8
+ {{ t("scopes") }}
9
+ </Tab>
10
+ </TabList>
11
+ <TabPanels>
12
+ <TabPanel value="pages">
13
+ <div class="flex flex-col gap-2">
14
+ <div
15
+ v-for="page in miniApp.integration.customPage?.pages"
16
+ class="flex flex-col gap-2 bg-slate-100 rounded-xl px-4 py-3"
17
+ >
18
+ <div class="flex items-center gap-2">
19
+ <MiniAppPageIcon
20
+ :iconType="page.iconType"
21
+ :icon="page.icon ?? ''"
22
+ class=""
23
+ />
24
+
25
+ <div class="font-semibold text-surface-700">
26
+ {{ page.title }}
27
+ </div>
28
+ </div>
29
+ <div class="flex flex-col pl-6">
30
+ <div class="text-surface-400 text-sm mt-1">
31
+ {{ page.description }}
32
+ </div>
33
+
34
+ <template v-if="!_.isEmpty(page.requiredPermissions)">
35
+ <Divider type="dashed" class="!my-3" />
36
+
37
+ <div class="flex items-center gap-2 flex-wrap">
38
+ <span class="text-surface-700 text-sm">
39
+ {{ t("miniAppLang.requiredPermissions") }}:
40
+ </span>
41
+ <div
42
+ v-for="requiredPermission in page.requiredPermissions"
43
+ class="bg-slate-300 px-2 py-0.5 rounded-md text-xs font-medium text-surface-600"
44
+ >
45
+ {{ requiredPermission }}
46
+ </div>
47
+ </div>
48
+ </template>
49
+ </div>
50
+ </div>
51
+ </div>
52
+ </TabPanel>
53
+ <TabPanel value="scopes">
54
+ <MiniAppFeatureScope :miniApp="miniApp" />
55
+ </TabPanel>
56
+ </TabPanels>
57
+ </Tabs>
58
+ </template>
59
+ <script setup lang="ts">
60
+ import { MiniAppDetail } from "~/simpleapp/generate/openapi";
61
+ import MiniAppPageIcon from "./MiniAppPageIcon.vue";
62
+ import MiniAppFeatureScope from "./MiniAppFeatureScope.vue";
63
+ import _ from "lodash";
64
+
65
+ const props = defineProps<{
66
+ miniApp: MiniAppDetail;
67
+ }>();
68
+ </script>
@@ -0,0 +1,53 @@
1
+ <template>
2
+ <div class="mb-8 text-surface-500">
3
+ {{ t("miniAppLang.scopeDescription") }}
4
+ </div>
5
+ <div class="space-y-3">
6
+ <div
7
+ v-for="(scopeList, resourceName) in scopes"
8
+ class="rounded-lg space-y-2"
9
+ >
10
+ <div class="font-semibold">
11
+ {{ t(resourceName.toLowerCase()) }}
12
+ </div>
13
+
14
+ <div class="grid grid-cols-2 gap-2">
15
+ <div
16
+ v-for="scope in scopeList"
17
+ class="space-x-2 text-sm bg-slate-100 rounded px-2 py-1 text-surface-600 font-medium"
18
+ >
19
+ <span>{{ _.startCase(scope) }}</span>
20
+ </div>
21
+ </div>
22
+
23
+ <Divider type="dashed" class="!mt-6 !mb-4" />
24
+ </div>
25
+ </div>
26
+ </template>
27
+
28
+ <script setup lang="ts">
29
+ import { MiniAppDetail } from "~/simpleapp/generate/openapi";
30
+ import _ from "lodash";
31
+
32
+ const props = defineProps<{
33
+ miniApp: MiniAppDetail;
34
+ }>();
35
+
36
+ const scopes = computed(() => {
37
+ if (!props?.miniApp?.integration?.scopes) {
38
+ return {};
39
+ }
40
+
41
+ const grouped: Record<string, string[]> = {};
42
+
43
+ for (const item of props?.miniApp?.integration?.scopes) {
44
+ const [prefix, suffix] = item.split(".");
45
+ if (!grouped[prefix]) {
46
+ grouped[prefix] = [];
47
+ }
48
+ grouped[prefix].push(suffix);
49
+ }
50
+
51
+ return grouped;
52
+ });
53
+ </script>
@@ -0,0 +1,49 @@
1
+ <template>
2
+ <div
3
+ class="drop-shadow-[0_10px_8px_rgba(197,197,197,0.25)]"
4
+ :class="{
5
+ 'size-20': size === 'xl',
6
+ 'size-16': size === 'lg',
7
+ 'size-14': !size || size === 'normal',
8
+ 'size-8': size === 'xs',
9
+ 'size-7': size === 'tiny',
10
+ 'size-6': size === 'tiny-1',
11
+ }"
12
+ >
13
+ <PrimevueAvatar
14
+ :image
15
+ :label="image ? undefined : displayLabel"
16
+ class="squircle !size-full aspect-square"
17
+ :class="{
18
+ 'text-xl': size === 'lg',
19
+ 'text-lg': !size || size === 'normal',
20
+ 'text-xs': size === 'xs',
21
+ 'text-6xl': size === 'xl',
22
+ 'text-tiny': size === 'tiny' || size === 'tiny-1',
23
+ }"
24
+ style="background-color: #dee9fc; color: #1a2551"
25
+ />
26
+ </div>
27
+ </template>
28
+
29
+ <script setup lang="ts">
30
+ import _ from "lodash";
31
+ import PrimevueAvatar from "primevue/avatar";
32
+
33
+ const props = defineProps<{
34
+ image?: string;
35
+ label?: string;
36
+ size?: "lg" | "normal" | "xs" | "xl" | "tiny" | "tiny-1";
37
+ }>();
38
+
39
+ const displayLabel = computed(() => {
40
+ if (!props.label) return undefined;
41
+
42
+ return props.label
43
+ .trim()
44
+ .split(/\s+/)
45
+ .slice(0, 2)
46
+ .map((word) => word.charAt(0).toUpperCase())
47
+ .join("");
48
+ });
49
+ </script>
@@ -30,9 +30,10 @@
30
30
  :title="miniApp.name"
31
31
  >
32
32
  <template #icon>
33
- <img
34
- :src="miniApp.logo"
35
- class="size-6 rounded-md object-contain"
33
+ <MiniAppIcon
34
+ :image="miniApp.logo"
35
+ :label="miniApp.name"
36
+ size="tiny"
36
37
  />
37
38
  </template>
38
39
  <template #title>
@@ -77,7 +78,7 @@
77
78
  </div>
78
79
  </template>
79
80
 
80
- <template v-if="$miniAppStore.isShowMiniAppMoreMenuButton">
81
+ <template v-if="$miniAppStore.showMiniAppMoreMenuButton">
81
82
  <MainmenuButton
82
83
  :id="'mainmenu-app-miniApps-page-more'"
83
84
  :to="getDocumentUrl('miniapp')"
@@ -96,6 +97,7 @@
96
97
  <script setup lang="ts">
97
98
  import IconPuzzle from "~/components/icon/IconPuzzle.vue";
98
99
  import MiniAppPageIcon from "./MiniAppPageIcon.vue";
100
+ import MiniAppIcon from "./MiniAppIcon.vue";
99
101
 
100
102
  const { $miniAppStore } = useNuxtApp();
101
103
  const displayItemCount = 3;
@@ -23,12 +23,17 @@
23
23
  </template>
24
24
 
25
25
  <script setup lang="ts">
26
- import { MiniappIntegrationPages } from "~/simpleapp/generate/openapi";
26
+ import {
27
+ MiniAppDetail,
28
+ MiniappIntegrationCustomPagePages,
29
+ } from "~/simpleapp/generate/openapi";
27
30
 
28
31
  const props = defineProps<{
29
- pageInfo: MiniappIntegrationPages;
32
+ miniApp: MiniAppDetail;
33
+ pageInfo: MiniappIntegrationCustomPagePages;
30
34
  miniAppCode: string;
31
35
  miniAppInstallationId: string;
36
+ developerPortalAppId: string;
32
37
  }>();
33
38
 
34
39
  const _xOrg = getPathPara("xorg", "");
@@ -52,10 +57,11 @@ const { iframeRef, onIframeLoad } = useMiniAppBridge(
52
57
  props.miniAppInstallationId,
53
58
  props.pageInfo,
54
59
  props.miniAppCode,
60
+ props.developerPortalAppId,
55
61
  );
56
62
 
57
63
  const iframeSource = computed(() => {
58
- return isDevMode()
64
+ return props.miniApp.env === "dev"
59
65
  ? props.pageInfo.sources.development
60
66
  : props.pageInfo.sources.production;
61
67
  });
@@ -1,17 +1,17 @@
1
1
  <template>
2
2
  <MiniAppRestrictedWarning
3
- v-if="!permission.status"
4
- :reason="permission.reason ?? ''"
3
+ v-if="!validation.valid"
4
+ :type="validation.type ?? ''"
5
5
  class="flex items-center justify-center mt-10"
6
6
  />
7
7
  <slot v-else />
8
8
  </template>
9
9
 
10
10
  <script setup lang="ts">
11
- import { MiniAppPermissionResult } from "../types/miniApp";
11
+ import { MiniAppValidationResp } from "../types/miniApp";
12
12
  import MiniAppRestrictedWarning from "./MiniAppRestrictedWarning.vue";
13
13
 
14
14
  defineProps<{
15
- permission: MiniAppPermissionResult;
15
+ validation: MiniAppValidationResp;
16
16
  }>();
17
17
  </script>
@@ -3,11 +3,11 @@
3
3
  <span
4
4
  class="px-3 py-1 text-sm font-semibold rounded bg-yellow-100 text-yellow-800"
5
5
  >
6
- {{ t(`miniAppLang.${reason}`) }}
6
+ {{ t(`miniAppLang.permission.${type}`) }}
7
7
  </span>
8
8
 
9
9
  <ButtonPrimary
10
- v-if="reason === 'packageTypeRestricted'"
10
+ v-if="type === 'miniAppFeature'"
11
11
  :label="t('miniAppLang.upgradePlan')"
12
12
  @click="handleUpgradePlan"
13
13
  />
@@ -16,7 +16,7 @@
16
16
 
17
17
  <script setup lang="ts">
18
18
  defineProps<{
19
- reason: string;
19
+ type: string;
20
20
  }>();
21
21
 
22
22
  function handleUpgradePlan() {
@@ -6,14 +6,14 @@
6
6
  {{ miniAppTitle }}
7
7
  </h1>
8
8
 
9
- <div v-if="$miniAppStore.isHasMiniAppFeature">
10
- <slot v-if="$miniAppStore.isCanUpdateSetting" name="action" />
9
+ <div v-if="$miniAppStore.validation('updateSetting').valid">
10
+ <slot name="action" />
11
11
  </div>
12
12
  </div>
13
13
 
14
14
  <MiniAppPermissionWrapper
15
15
  v-if="miniApp"
16
- :permission="$miniAppStore.checkCanUpdateSetting(miniApp)"
16
+ :validation="$miniAppStore.validation('updateSetting')"
17
17
  >
18
18
  <slot />
19
19
  </MiniAppPermissionWrapper>
@@ -20,12 +20,12 @@
20
20
  <template #default>
21
21
  <div class="space-y-4" v-if="!_.isEmpty(schema)">
22
22
  <p
23
- v-if="miniApp?.integration?.settings?.note"
23
+ v-if="miniApp?.integration?.customPage?.setting?.note"
24
24
  class="text-sm text-gray-600 whitespace-pre-line"
25
25
  >
26
26
  {{
27
27
  t("miniAppLang.miniAppSettingNote", {
28
- miniAppNote: miniApp.integration.settings.note ?? "",
28
+ miniAppNote: miniApp.integration.customPage.setting.note ?? "",
29
29
  })
30
30
  }}
31
31
  </p>
@@ -3,7 +3,7 @@
3
3
 
4
4
  <MiniAppPermissionWrapper
5
5
  v-if="!$miniAppStore.isFetchingInstalledMiniApps"
6
- :permission="permission"
6
+ :validation="$miniAppStore.validatePageAccess(miniAppCode, pageCode)"
7
7
  >
8
8
  <slot />
9
9
  </MiniAppPermissionWrapper>
@@ -12,38 +12,8 @@
12
12
  <script setup lang="ts">
13
13
  import MiniAppPermissionWrapper from "./MiniAppPermissionWrapper.vue";
14
14
 
15
- const props = defineProps<{
15
+ defineProps<{
16
16
  miniAppCode: string;
17
17
  pageCode: string;
18
18
  }>();
19
-
20
- const { $miniAppStore } = useNuxtApp();
21
-
22
- const miniApp = computed(() => {
23
- return $miniAppStore.installedMiniApps.find(
24
- (item) => item.code === props.miniAppCode,
25
- );
26
- });
27
-
28
- const permission = computed(() => {
29
- const checkHasFeature = $miniAppStore.checkHasFeature();
30
- if (!checkHasFeature.status) return checkHasFeature;
31
-
32
- const checkIsInstalled = $miniAppStore.checkIsInstalled(props.miniAppCode);
33
- if (!checkIsInstalled.status) return checkIsInstalled;
34
-
35
- if (!miniApp.value) {
36
- return {
37
- status: false,
38
- reason: "unknownMiniApp",
39
- };
40
- }
41
-
42
- const checkHasRequiredPlan = $miniAppStore.checkHasRequiredPlan(
43
- miniApp.value,
44
- );
45
- if (!checkHasRequiredPlan.status) return checkHasRequiredPlan;
46
-
47
- return $miniAppStore.checkCanAccess(props.miniAppCode, props.pageCode);
48
- });
49
19
  </script>
@@ -16,7 +16,7 @@
16
16
  </div>
17
17
 
18
18
  <div class="p-4">
19
- <img :src="item.logo" class="size-16 object-contain" />
19
+ <MiniAppIcon :image="item.logo" :label="item.name" size="lg" />
20
20
  </div>
21
21
 
22
22
  <div class="text-sm text-gray-600 text-center line-clamp-2">
@@ -27,18 +27,19 @@
27
27
 
28
28
  <script setup lang="ts">
29
29
  import { MiniappStatusEnum } from "~/enums/enums.generate";
30
- import { Miniapp } from "~/simpleapp/generate/openapi";
30
+ import { MiniAppDetail } from "~/simpleapp/generate/openapi";
31
31
  import MiniAppIntegrationItemBadge from "./MiniAppIntegrationItemBadge.vue";
32
+ import MiniAppIcon from "../MiniAppIcon.vue";
32
33
 
33
34
  defineProps<{
34
- item: Miniapp;
35
+ item: MiniAppDetail;
35
36
  }>();
36
37
 
37
38
  const emits = defineEmits<{
38
- (event: "miniAppClick", item: Miniapp): void;
39
+ (event: "miniAppClick", item: MiniAppDetail): void;
39
40
  }>();
40
41
 
41
- function handleMiniAppClick(item: Miniapp) {
42
+ function handleMiniAppClick(item: MiniAppDetail) {
42
43
  if (item.status === MiniappStatusEnum.UPCOMING) return;
43
44
 
44
45
  if (item._id) {
@@ -5,11 +5,12 @@
5
5
  :class="{
6
6
  'bg-emerald-500': badgeType === 'available',
7
7
  'bg-yellow-400': badgeType === 'comingSoon',
8
+ 'bg-slate-400': badgeType === 'dev',
8
9
  }"
9
10
  >
10
11
  {{ t(`miniAppLang.${badgeType}`) }}
11
12
  </span>
12
- <span
13
+ <!-- <span
13
14
  v-else
14
15
  class="bg-slate-200/50 text-surface-500 text-[0.65rem] px-2 font-bold py-0.5 rounded-md uppercase"
15
16
  >
@@ -27,28 +28,33 @@
27
28
  })
28
29
  }}
29
30
  </template>
30
- </span>
31
+ </span> -->
31
32
  </template>
32
33
 
33
34
  <script setup lang="ts">
34
- import { Miniapp } from "~/simpleapp/generate/openapi";
35
+ import { MiniappEnvEnum } from "~/enums/enums.generate";
36
+ import { Miniapp, MiniAppDetail } from "~/simpleapp/generate/openapi";
35
37
 
36
38
  const props = defineProps<{
37
- item: Miniapp;
39
+ item: MiniAppDetail;
38
40
  }>();
39
41
 
40
42
  const { $miniAppStore } = useNuxtApp();
41
43
 
42
44
  const badgeType = computed(() => {
45
+ if (props.item.env === MiniappEnvEnum.DEV) {
46
+ return "dev";
47
+ }
48
+
49
+ if (!$miniAppStore.hasMiniAppFeature) {
50
+ return "noFeature";
51
+ }
52
+
43
53
  if (props.item.status === "upcoming") {
44
54
  return "comingSoon";
45
55
  }
46
56
 
47
- if ($miniAppStore.hasRequiredPlan(props.item)) {
48
- if (!$miniAppStore.isHasMiniAppFeature) {
49
- return "noFeature";
50
- }
51
-
57
+ if (props.item.hasRequiredPlan) {
52
58
  return "available";
53
59
  }
54
60
 
@@ -19,16 +19,16 @@
19
19
  </template>
20
20
  <script setup lang="ts">
21
21
  import UndrawNodata from "~/components/icon/UndrawNodata.vue";
22
- import { Miniapp } from "~/simpleapp/generate/openapi";
22
+ import { MiniAppDetail } from "~/simpleapp/generate/openapi";
23
23
  import MiniAppIntegrationItem from "./MiniAppIntegrationItem.vue";
24
24
 
25
- defineProps<{ items: Miniapp[] | undefined }>();
25
+ defineProps<{ items: MiniAppDetail[] | undefined }>();
26
26
 
27
27
  const emits = defineEmits<{
28
- (event: "miniAppClick", item: Miniapp): void;
28
+ (event: "miniAppClick", item: MiniAppDetail): void;
29
29
  }>();
30
30
 
31
- function handleMiniAppClick(item: Miniapp) {
31
+ function handleMiniAppClick(item: MiniAppDetail) {
32
32
  emits("miniAppClick", item);
33
33
  }
34
34
  </script>