@navservice/assinatura 1.47.0 → 1.48.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.
@@ -1,4 +1,5 @@
1
1
  import { InferInsertModel, InferSelectModel } from 'drizzle-orm';
2
+ import { TypesCore } from "@navservice/core";
2
3
  export declare const AssinaturaStatusEnum: readonly ["active", "canceled", "incomplete", "incomplete_expired", "past_due", "paused", "trialing", "unpaid"];
3
4
  export declare const schema_assinatura: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
4
5
  name: "assinatura";
@@ -322,3 +323,7 @@ export declare const schema_assinatura: import("drizzle-orm/sqlite-core").SQLite
322
323
  }>;
323
324
  export type AssinaturaSelect = InferSelectModel<typeof schema_assinatura>;
324
325
  export type AssinaturaInsert = InferInsertModel<typeof schema_assinatura>;
326
+ export type BuscarPeloUsuarioId = {
327
+ app: TypesCore.Controller.Usuario.TokenPayload["app"];
328
+ usuario_id: string;
329
+ };
@@ -20,11 +20,6 @@ interface AssinaturaState {
20
20
  }
21
21
  export declare const contexto_assinatura: {
22
22
  api: {
23
- criar: (props: t.Controller.Assinatura.Criar.Input) => Promise<t.Controller.Assinatura.Criar.Output | null>;
24
- buscar_pelo_id: (props: t.Controller.Assinatura.BuscarPeloId.Input) => Promise<t.Controller.Assinatura.BuscarPeloId.Output | null>;
25
- buscar_pelo_filtro: (props: t.Controller.Assinatura.BuscarPeloFiltro.Input, setLoading?: boolean) => Promise<t.Controller.Assinatura.BuscarPeloFiltro.Output | null>;
26
- atualizar_pelo_id: (props: t.Controller.Assinatura.AtualizarPeloId.Input) => Promise<t.Controller.Assinatura.AtualizarPeloId.Output | null>;
27
- deletar_pelo_id: (props: t.Controller.Assinatura.DeletarPeloId.Input) => Promise<t.Controller.Assinatura.DeletarPeloId.Output | null>;
28
23
  buscar_produto_stripe: () => Promise<void>;
29
24
  criar_checkout_session: (props: t.Controller.Assinatura.CriarCheckoutSession.Input) => Promise<t.Controller.Assinatura.CriarCheckoutSession.Output | null>;
30
25
  gerenciar: (props: t.Controller.Assinatura.Gerenciar.Input) => Promise<void>;
package/build/es/index.js CHANGED
@@ -18812,6 +18812,17 @@ sqliteTable('assinatura', {
18812
18812
  })
18813
18813
  });
18814
18814
  })(TypeControllerAssinatura.BuscarPeloId || (TypeControllerAssinatura.BuscarPeloId = {}));
18815
+ (function(BuscarPeloUsuarioId) {
18816
+ BuscarPeloUsuarioId.route = "/api/assinatura/usuario/:id";
18817
+ BuscarPeloUsuarioId.InputSchema = v4.object({
18818
+ data: v4.object({
18819
+ assinatura: v4.object({
18820
+ usuario_id: v4.uuidv4(),
18821
+ app: v4["enum"](es_types.Controller.Usuario.AppEnum)
18822
+ })
18823
+ })
18824
+ });
18825
+ })(TypeControllerAssinatura.BuscarPeloUsuarioId || (TypeControllerAssinatura.BuscarPeloUsuarioId = {}));
18815
18826
  (function(AtualizarPeloId) {
18816
18827
  AtualizarPeloId.route = "/api/assinatura/:id";
18817
18828
  AtualizarPeloId.InputSchema = v4.object({
@@ -19074,109 +19085,6 @@ const contexto_assinatura_store = react_create()(immer_immer(()=>({
19074
19085
  })));
19075
19086
  const contexto_assinatura = new class {
19076
19087
  api = {
19077
- criar: async (props)=>{
19078
- try {
19079
- this.set_state((s)=>{
19080
- s.loading = true;
19081
- });
19082
- const response = await src_utils.api.servidor_pricipal.post({
19083
- baseURLKey: "PUBLIC_BASE_URL_SERVICE_ASSINATURA",
19084
- url: shared_types.Controller.Assinatura.Criar.route,
19085
- data: props
19086
- });
19087
- const data = response?.data?.results ?? null;
19088
- if (data) this.set_state((s)=>{
19089
- s.assinaturaSelecionada = data;
19090
- });
19091
- return data;
19092
- } finally{
19093
- this.set_state((s)=>{
19094
- s.loading = false;
19095
- });
19096
- }
19097
- },
19098
- buscar_pelo_id: async (props)=>{
19099
- try {
19100
- this.set_state((s)=>{
19101
- s.loading = true;
19102
- });
19103
- const url = shared_types.Controller.Assinatura.BuscarPeloId.route.replace(":id", props.data.assinatura.usuario_id);
19104
- const response = await src_utils.api.servidor_pricipal.get({
19105
- baseURLKey: "PUBLIC_BASE_URL_SERVICE_ASSINATURA",
19106
- url: url
19107
- });
19108
- const data = response?.data?.results ?? null;
19109
- if (data) this.set_state((s)=>{
19110
- s.assinaturaSelecionada = data;
19111
- });
19112
- return data;
19113
- } finally{
19114
- this.set_state((s)=>{
19115
- s.loading = false;
19116
- });
19117
- }
19118
- },
19119
- buscar_pelo_filtro: async (props, setLoading = false)=>{
19120
- try {
19121
- if (setLoading) this.set_state((s)=>{
19122
- s.loading = true;
19123
- });
19124
- const response = await src_utils.api.servidor_pricipal.get({
19125
- baseURLKey: "PUBLIC_BASE_URL_SERVICE_ASSINATURA",
19126
- url: shared_types.Controller.Assinatura.BuscarPeloFiltro.route,
19127
- params: props.filtros.assinatura
19128
- });
19129
- const data = response?.data?.results ?? null;
19130
- if (data) this.set_state((s)=>{
19131
- s.assinaturas = data.data.assinatura;
19132
- s.paginacao = data.data.paginacao;
19133
- });
19134
- return data;
19135
- } finally{
19136
- if (setLoading) this.set_state((s)=>{
19137
- s.loading = false;
19138
- });
19139
- }
19140
- },
19141
- atualizar_pelo_id: async (props)=>{
19142
- try {
19143
- this.set_state((s)=>{
19144
- s.loading = true;
19145
- });
19146
- const url = shared_types.Controller.Assinatura.AtualizarPeloId.route.replace(":id", props.data.assinatura.usuario_id);
19147
- const response = await src_utils.api.servidor_pricipal.patch({
19148
- baseURLKey: "PUBLIC_BASE_URL_SERVICE_ASSINATURA",
19149
- url,
19150
- data: props
19151
- });
19152
- const data = response?.data?.results ?? null;
19153
- if (data) this.set_state((s)=>{
19154
- s.assinaturaSelecionada = data;
19155
- });
19156
- return data;
19157
- } finally{
19158
- this.set_state((s)=>{
19159
- s.loading = false;
19160
- });
19161
- }
19162
- },
19163
- deletar_pelo_id: async (props)=>{
19164
- try {
19165
- this.set_state((s)=>{
19166
- s.loading = true;
19167
- });
19168
- const url = shared_types.Controller.Assinatura.DeletarPeloId.route.replace(":id", props.data._id);
19169
- const response = await src_utils.api.servidor_pricipal["delete"]({
19170
- baseURLKey: "PUBLIC_BASE_URL_SERVICE_ASSINATURA",
19171
- url: url
19172
- });
19173
- return response?.data?.results ?? null;
19174
- } finally{
19175
- this.set_state((s)=>{
19176
- s.loading = false;
19177
- });
19178
- }
19179
- },
19180
19088
  buscar_produto_stripe: async ()=>{
19181
19089
  try {
19182
19090
  this.set_state((s)=>{
@@ -3,7 +3,8 @@ import Stripe from "stripe";
3
3
  import z4 from "zod/v4";
4
4
  import t from "..";
5
5
  declare namespace TypeControllerAssinatura {
6
- const AssinaturaBaseSchema: z4.ZodObject<{
6
+ export type PlanName = "FREE" | "ESSENTIAL" | "BUSINESS" | "ULTIMATE";
7
+ export const AssinaturaBaseSchema: z4.ZodObject<{
7
8
  _id: z4.ZodString;
8
9
  usuario_id: z4.ZodString;
9
10
  usuario_tipo: z4.ZodEnum<{
@@ -38,7 +39,8 @@ declare namespace TypeControllerAssinatura {
38
39
  stripe_latest_invoice_id: z4.ZodOptional<z4.ZodNullable<z4.ZodString>>;
39
40
  ativo: z4.ZodUnion<readonly [z4.ZodLiteral<1>, z4.ZodLiteral<0>]>;
40
41
  }, z4.core.$strip>;
41
- namespace Criar {
42
+ type AssinaturaBase = z4.infer<typeof AssinaturaBaseSchema>;
43
+ export namespace Criar {
42
44
  const route: "/api/assinatura";
43
45
  const InputSchema: z4.ZodObject<{
44
46
  data: z4.ZodObject<{
@@ -67,12 +69,12 @@ declare namespace TypeControllerAssinatura {
67
69
  type Input = z4.infer<typeof InputSchema>;
68
70
  type Output = {
69
71
  data: {
70
- assinatura: z4.infer<typeof AssinaturaBaseSchema>;
72
+ assinatura: AssinaturaBase;
71
73
  };
72
74
  };
73
75
  type Response = AxiosResponse<t.Geral.Response.C.Output<Output>>;
74
76
  }
75
- namespace BuscarPeloFiltro {
77
+ export namespace BuscarPeloFiltro {
76
78
  const route: "/api/assinatura";
77
79
  const InputSchema: z4.ZodObject<{
78
80
  filtros: z4.ZodObject<{
@@ -102,12 +104,12 @@ declare namespace TypeControllerAssinatura {
102
104
  itens_por_pagina: number;
103
105
  total_itens_pagina_atual: number;
104
106
  };
105
- assinatura: z4.infer<typeof AssinaturaBaseSchema>[];
107
+ assinatura: AssinaturaBase[];
106
108
  };
107
109
  };
108
110
  type Response = AxiosResponse<t.Geral.Response.C.Output<Output>>;
109
111
  }
110
- namespace BuscarPeloId {
112
+ export namespace BuscarPeloId {
111
113
  const route: "/api/assinatura/:id";
112
114
  const InputSchema: z4.ZodObject<{
113
115
  data: z4.ZodObject<{
@@ -119,12 +121,38 @@ declare namespace TypeControllerAssinatura {
119
121
  type Input = z4.infer<typeof InputSchema>;
120
122
  type Output = {
121
123
  data: {
122
- assinatura: z4.infer<typeof AssinaturaBaseSchema>;
124
+ assinatura: AssinaturaBase;
123
125
  };
124
126
  };
125
127
  type Response = AxiosResponse<t.Geral.Response.C.Output<Output>>;
126
128
  }
127
- namespace AtualizarPeloId {
129
+ export namespace BuscarPeloUsuarioId {
130
+ const route: "/api/assinatura/usuario/:id";
131
+ const InputSchema: z4.ZodObject<{
132
+ data: z4.ZodObject<{
133
+ assinatura: z4.ZodObject<{
134
+ usuario_id: z4.ZodUUID;
135
+ app: z4.ZodEnum<{
136
+ "service-usuario": "service-usuario";
137
+ "service-pages": "service-pages";
138
+ "service-assinatura": "service-assinatura";
139
+ "service-bucket": "service-bucket";
140
+ }>;
141
+ }, z4.core.$strip>;
142
+ }, z4.core.$strip>;
143
+ }, z4.core.$strip>;
144
+ type Input = z4.infer<typeof InputSchema>;
145
+ type Output = {
146
+ data: {
147
+ assinatura: {
148
+ status: AssinaturaBase["status"];
149
+ plano: PlanName;
150
+ };
151
+ };
152
+ };
153
+ type Response = AxiosResponse<t.Geral.Response.C.Output<Output>>;
154
+ }
155
+ export namespace AtualizarPeloId {
128
156
  const route: "/api/assinatura/:id";
129
157
  const InputSchema: z4.ZodObject<{
130
158
  data: z4.ZodObject<{
@@ -157,12 +185,12 @@ declare namespace TypeControllerAssinatura {
157
185
  type Input = z4.infer<typeof InputSchema>;
158
186
  type Output = {
159
187
  data: {
160
- assinatura: z4.infer<typeof AssinaturaBaseSchema>;
188
+ assinatura: AssinaturaBase;
161
189
  };
162
190
  };
163
191
  type Response = AxiosResponse<t.Geral.Response.C.Output<Output>>;
164
192
  }
165
- namespace DeletarPeloId {
193
+ export namespace DeletarPeloId {
166
194
  const route: "/api/assinatura/:id";
167
195
  const InputSchema: z4.ZodObject<{
168
196
  data: z4.ZodObject<{
@@ -172,12 +200,12 @@ declare namespace TypeControllerAssinatura {
172
200
  type Input = z4.infer<typeof InputSchema>;
173
201
  type Output = {
174
202
  data: {
175
- assinatura: {};
203
+ assinatura: AssinaturaBase;
176
204
  };
177
205
  };
178
206
  type Response = AxiosResponse<t.Geral.Response.C.Output<Output>>;
179
207
  }
180
- namespace BuscarProdutoStripe {
208
+ export namespace BuscarProdutoStripe {
181
209
  const route: "/api/assinatura/produto";
182
210
  type Output = {
183
211
  data: {
@@ -189,7 +217,7 @@ declare namespace TypeControllerAssinatura {
189
217
  };
190
218
  type Response = AxiosResponse<t.Geral.Response.C.Output<Output>>;
191
219
  }
192
- namespace CriarCheckoutSession {
220
+ export namespace CriarCheckoutSession {
193
221
  const route: "/api/assinatura/checkout";
194
222
  const InputSchema: z4.ZodObject<{
195
223
  data: z4.ZodObject<{
@@ -209,18 +237,18 @@ declare namespace TypeControllerAssinatura {
209
237
  };
210
238
  };
211
239
  }
212
- namespace Cancelar {
240
+ export namespace Cancelar {
213
241
  const route: "/api/assinatura";
214
242
  const InputSchema: z4.ZodObject<{}, z4.core.$strip>;
215
243
  type Input = z4.infer<typeof InputSchema>;
216
244
  type Output = {
217
245
  data: {
218
- assinatura: z4.infer<typeof AssinaturaBaseSchema>;
246
+ assinatura: AssinaturaBase;
219
247
  };
220
248
  };
221
249
  type Response = AxiosResponse<t.Geral.Response.C.Output<Output>>;
222
250
  }
223
- namespace Gerenciar {
251
+ export namespace Gerenciar {
224
252
  const route: "/api/assinatura/gerenciar";
225
253
  const InputSchema: z4.ZodObject<{
226
254
  data: z4.ZodObject<{
@@ -237,7 +265,7 @@ declare namespace TypeControllerAssinatura {
237
265
  };
238
266
  type Response = AxiosResponse<t.Geral.Response.C.Output<Output>>;
239
267
  }
240
- namespace UpgradeEDownGradeAssinatura {
268
+ export namespace UpgradeEDownGradeAssinatura {
241
269
  const route: "/api/assinatura/upgrade_downgrade";
242
270
  const InputSchema: z4.ZodObject<{
243
271
  data: z4.ZodObject<{
@@ -254,5 +282,6 @@ declare namespace TypeControllerAssinatura {
254
282
  };
255
283
  type Response = AxiosResponse<t.Geral.Response.C.Output<Output>>;
256
284
  }
285
+ export {};
257
286
  }
258
287
  export default TypeControllerAssinatura;
@@ -14,17 +14,14 @@ declare namespace t {
14
14
  namespace Geral {
15
15
  export import Response = TypeResponse;
16
16
  interface Env {
17
- STRIPE_PRICES_ID_SERVICE_ASSINATURA?: string;
18
- STRIPE_PRICES_ID_SERVICE_USUARIO?: string;
19
- STRIPE_PRICES_ID_SERVICE_PAGES?: string;
17
+ CORS_ORIGIN?: string;
18
+ NODE_ENV?: "PRODUCAO" | "SANDBOX";
20
19
  STRIPE_SECRET_KEY?: string;
21
20
  STRIPE_SECRET_KEY_WEBHOOKS_RESPONSE?: string;
22
21
  RESEND_API_KEY?: string;
23
22
  JSON_WEB_TOKEN_AUTH_USER?: string;
24
23
  PUBLIC_BASE_URL_SERVICE_ASSINATURA?: string;
25
24
  PUBLIC_GOOGLE_CLIENT_ID_AUTH0?: string;
26
- PUBLIC_BASE_URL_SERVICE_USUARIO?: string;
27
- CORS_ORIGIN?: string;
28
25
  DB_SERVICE_ASSINATURA?: D1Database;
29
26
  ASSETS?: Fetcher;
30
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navservice/assinatura",
3
- "version": "1.47.0",
3
+ "version": "1.48.0",
4
4
  "description": "Service de autenticação de usuários unificado",
5
5
  "type": "module",
6
6
  "main": "./build/lib/index.js",