@autentikar/step 2.2.4 → 2.2.9

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.
package/dist/context.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { S as StorageItem, a as Step } from './index-CmOrkCZE.js';
1
+ import { S as StorageItem, C as Context, a as Step } from './index-CnuOwYb5.js';
2
2
  import 'file-type/core';
3
3
  import 'zod';
4
4
 
@@ -52,5 +52,6 @@ declare let preference: Preference;
52
52
  declare let system: System;
53
53
  declare let kv: KV;
54
54
  declare let asset: Storage;
55
+ declare let context: Context;
55
56
 
56
- export { type KV, type Params, type Preference, Step, type Storage, type System, asset, kv, params, preference, step, system };
57
+ export { Context, type KV, type Params, type Preference, Step, type Storage, type System, asset, context, kv, params, preference, step, system };
package/dist/context.js CHANGED
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var context_exports = {};
22
22
  __export(context_exports, {
23
23
  asset: () => asset,
24
+ context: () => context,
24
25
  kv: () => kv,
25
26
  params: () => params,
26
27
  preference: () => preference,
@@ -34,9 +35,11 @@ var preference;
34
35
  var system;
35
36
  var kv;
36
37
  var asset;
38
+ var context;
37
39
  // Annotate the CommonJS export names for ESM import in node:
38
40
  0 && (module.exports = {
39
41
  asset,
42
+ context,
40
43
  kv,
41
44
  params,
42
45
  preference,
@@ -1,30 +1,6 @@
1
1
  import * as file_type_core from 'file-type/core';
2
2
  import { z } from 'zod';
3
3
 
4
- interface Step {
5
- params<TValue = unknown>(extend?: unknown): Promise<TValue | undefined>;
6
- milestone(type: string, status: string, success: boolean, session?: string): Promise<void>;
7
- future(type: string, id: string, ttl: number): Promise<void>;
8
- /** @deprecated Use addStepData*/
9
- identity(organization_id: string, instance_id: string, link_session: string | undefined, identity: IdentityDto, data: StepIdentityData): Promise<any>;
10
- addStepData(link_session: string | undefined, identity: IdentityDto, data: StepIdentityData): Promise<any>;
11
- getStepData<T extends StepIdentityData["type"]>(type: T, link_session: string | undefined): Promise<Extract<StepIdentityData, {
12
- type: T;
13
- }> | undefined>;
14
- addVendorStat(params: {
15
- vendor: string;
16
- service: string;
17
- amount?: number;
18
- transaction_id: string;
19
- meta?: Record<string, unknown>;
20
- }): Promise<void>;
21
- /** Step definition */
22
- definition(step_id: string): Promise<{
23
- /** parametros de step */
24
- params: Record<string, unknown>;
25
- } | undefined>;
26
- }
27
-
28
4
  interface AutentikarRequestInit extends RequestInit {
29
5
  host: string;
30
6
  organization?: {
@@ -47,7 +23,7 @@ interface AutentikarRequestInit extends RequestInit {
47
23
  /** @deprecated */
48
24
  staging: Staging;
49
25
  }
50
- declare class AutentikarRequest extends Request {
26
+ declare class AutentikarRequest<OUTPUT extends string = string> extends Request {
51
27
  readonly organization?: AutentikarRequestInit["organization"];
52
28
  readonly step?: AutentikarRequestInit["step"];
53
29
  readonly instance?: AutentikarRequestInit["instance"];
@@ -55,7 +31,7 @@ declare class AutentikarRequest extends Request {
55
31
  readonly staging?: Staging;
56
32
  readonly link_session: string | undefined;
57
33
  readonly params?: unknown;
58
- readonly output?: Record<string, string>;
34
+ readonly output?: Record<OUTPUT, string>;
59
35
  readonly host?: string;
60
36
  readonly flow: {
61
37
  id: string;
@@ -81,6 +57,62 @@ declare class AutentikarResponse extends Response {
81
57
  static json(data: any, init: AutentikarResponseInit): AutentikarResponse;
82
58
  }
83
59
 
60
+ interface Step {
61
+ /** @deprecated */
62
+ params<TValue = unknown>(extend?: unknown): Promise<TValue | undefined>;
63
+ milestone(type: string, status: string, success: boolean, session?: string): Promise<void>;
64
+ future(type: string, id: string, ttl: number): Promise<void>;
65
+ addStepData(link_session: string | undefined, identity: IdentityDto, data: StepIdentityData): Promise<any>;
66
+ getStepData<T extends StepIdentityData["type"]>(type: T, link_session: string | undefined): Promise<Extract<StepIdentityData, {
67
+ type: T;
68
+ }> | undefined>;
69
+ addVendorStat(params: {
70
+ vendor: string;
71
+ service: string;
72
+ amount?: number;
73
+ transaction_id: string;
74
+ meta?: Record<string, unknown>;
75
+ }): Promise<void>;
76
+ /** Step definition */
77
+ definition(): Promise<{
78
+ /** Parametros de step, se configuran en consola, no poseen contexto de ejecución. */
79
+ params: Record<string, unknown>;
80
+ } | undefined>;
81
+ }
82
+
83
+ declare class StepRequest implements Step {
84
+ private readonly stepDatasource;
85
+ constructor(stepDatasource: Step);
86
+ definition(): Promise<{
87
+ params: Record<string, unknown>;
88
+ } | undefined>;
89
+ addStepData(link_session: string | undefined, identity: IdentityDto, data: StepIdentityData): Promise<any>;
90
+ getStepData<T extends StepIdentityData["type"]>(type: T, link_session: string | undefined): Promise<Extract<StepIdentityData, {
91
+ type: T;
92
+ }> | undefined>;
93
+ addVendorStat(params: {
94
+ vendor: string;
95
+ service: string;
96
+ amount?: number;
97
+ transaction_id: string;
98
+ meta?: Record<string, unknown>;
99
+ }): Promise<void>;
100
+ future(type: string, id: string, ttl: number): Promise<void>;
101
+ milestone(type: string, status: string, success: boolean, session?: string): Promise<void>;
102
+ params<TValue = unknown>(extend?: unknown): Promise<TValue | undefined>;
103
+ }
104
+
105
+ interface Context {
106
+ /** scoped params from method */
107
+ params<TValue = unknown>(extend?: unknown): Promise<TValue | undefined>;
108
+ }
109
+
110
+ declare class ContextRequest implements Context {
111
+ private readonly contextDatasource;
112
+ constructor(contextDatasource: Context);
113
+ params<TValue = unknown>(extend?: unknown): Promise<TValue | undefined>;
114
+ }
115
+
84
116
  type StepIdentityData = {
85
117
  type: "SOURCE_FACE_2D";
86
118
  face: string;
@@ -119,28 +151,6 @@ type StepIdentityData = {
119
151
  text?: string;
120
152
  consent_id: string;
121
153
  };
122
- declare class StepRequest implements Step {
123
- private step;
124
- constructor(params: Step);
125
- definition(step_id: string): Promise<{
126
- params: Record<string, unknown>;
127
- } | undefined>;
128
- addStepData(link_session: string | undefined, identity: IdentityDto, data: StepIdentityData): Promise<any>;
129
- getStepData<T extends StepIdentityData["type"]>(type: T, link_session: string | undefined): Promise<Extract<StepIdentityData, {
130
- type: T;
131
- }> | undefined>;
132
- addVendorStat(params: {
133
- vendor: string;
134
- service: string;
135
- amount?: number;
136
- transaction_id: string;
137
- meta?: Record<string, unknown>;
138
- }): Promise<void>;
139
- future(type: string, id: string, ttl: number): Promise<void>;
140
- milestone(type: string, status: string, success: boolean, session?: string): Promise<void>;
141
- params<TValue = unknown>(extend?: unknown): Promise<TValue | undefined>;
142
- identity(organization_id: string, instance_id: string, link_session: string | undefined, identity: IdentityDto, data: StepIdentityData): Promise<any>;
143
- }
144
154
  declare const AppEnvironmentsSchema: z.ZodObject<{
145
155
  STAGING: z.ZodEnum<["LOCAL", "QA", "PROD"]>;
146
156
  STEP_TYPE: z.ZodString;
@@ -191,8 +201,11 @@ declare class StorageItem {
191
201
  getBase64(): string;
192
202
  getContenType(): Promise<file_type_core.MimeType | "unknown">;
193
203
  }
194
- type Method = (req: AutentikarRequest) => Promise<AutentikarResponse>;
195
- type Resource = (req: AutentikarRequest) => Promise<AutentikarResponse>;
204
+ type GenericOutput = "success" | "failure";
205
+ type BaseOutput = GenericOutput | (string & {});
206
+ type MethodOutputDescription<T extends string> = Record<T | GenericOutput, string>;
207
+ type Method<OUTPUT extends string = never> = (req: AutentikarRequest<BaseOutput | OUTPUT>) => Promise<AutentikarResponse>;
208
+ type Resource<OUTPUT extends never> = (req: AutentikarRequest<OUTPUT>) => Promise<AutentikarResponse>;
196
209
  type StepEvent = (req: AutentikarRequest) => Promise<AutentikarResponse>;
197
210
  type AppEnvVariables = {
198
211
  instance: {
@@ -252,4 +265,4 @@ declare class StepContext {
252
265
  isExpired(): boolean | 0 | undefined;
253
266
  }
254
267
 
255
- export { type AppEnv as A, FlowContext as F, type IdentityDto as I, type Method as M, type PersistentType as P, type Resource as R, StorageItem as S, type Step as a, type AppEnvVariables as b, type AppEnvironments as c, AutentikarRequest as d, AutentikarResponse as e, IdentitySchemaDto as f, type MethodContextFlow as g, type MethodContextInstance as h, type MethodContextOrganization as i, type MethodContextStep as j, type Staging as k, StepContext as l, StepDefinition as m, type StepEvent as n, type StepIdentityData as o, StepInstance as p, StepRequest as q };
268
+ export { type AppEnv as A, type Context as C, FlowContext as F, type IdentityDto as I, type Method as M, type PersistentType as P, type Resource as R, StorageItem as S, type Step as a, type AppEnvVariables as b, type AppEnvironments as c, AutentikarRequest as d, AutentikarResponse as e, ContextRequest as f, IdentitySchemaDto as g, type MethodContextFlow as h, type MethodContextInstance as i, type MethodContextOrganization as j, type MethodContextStep as k, type MethodOutputDescription as l, type Staging as m, StepContext as n, StepDefinition as o, type StepEvent as p, type StepIdentityData as q, StepInstance as r, StepRequest as s };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import 'file-type/core';
2
2
  import 'zod';
3
- export { A as AppEnv, b as AppEnvVariables, c as AppEnvironments, d as AutentikarRequest, e as AutentikarResponse, F as FlowContext, I as IdentityDto, f as IdentitySchemaDto, M as Method, g as MethodContextFlow, h as MethodContextInstance, i as MethodContextOrganization, j as MethodContextStep, P as PersistentType, R as Resource, k as Staging, l as StepContext, m as StepDefinition, n as StepEvent, o as StepIdentityData, p as StepInstance, q as StepRequest, S as StorageItem } from './index-CmOrkCZE.js';
3
+ export { A as AppEnv, b as AppEnvVariables, c as AppEnvironments, d as AutentikarRequest, e as AutentikarResponse, f as ContextRequest, F as FlowContext, I as IdentityDto, g as IdentitySchemaDto, M as Method, h as MethodContextFlow, i as MethodContextInstance, j as MethodContextOrganization, k as MethodContextStep, l as MethodOutputDescription, P as PersistentType, R as Resource, m as Staging, n as StepContext, o as StepDefinition, p as StepEvent, q as StepIdentityData, r as StepInstance, s as StepRequest, S as StorageItem } from './index-CnuOwYb5.js';
package/dist/index.js CHANGED
@@ -32,6 +32,7 @@ var index_exports = {};
32
32
  __export(index_exports, {
33
33
  AutentikarRequest: () => AutentikarRequest,
34
34
  AutentikarResponse: () => AutentikarResponse,
35
+ ContextRequest: () => ContextRequest,
35
36
  FlowContext: () => FlowContext,
36
37
  IdentitySchemaDto: () => IdentitySchemaDto,
37
38
  StepContext: () => StepContext,
@@ -53,6 +54,7 @@ var AutentikarRequest = class extends Request {
53
54
  staging;
54
55
  link_session;
55
56
  params;
57
+ // public readonly output?: Record<OUTPUT, string>;
56
58
  output;
57
59
  host;
58
60
  flow;
@@ -94,43 +96,60 @@ var AutentikarResponse = class _AutentikarResponse extends Response {
94
96
  }
95
97
  };
96
98
 
97
- // src/index.ts
99
+ // src/request/step.ts
98
100
  var StepRequest = class {
99
- step;
100
- constructor(params) {
101
- this.step = params;
101
+ constructor(stepDatasource) {
102
+ this.stepDatasource = stepDatasource;
102
103
  }
103
- async definition(step_id) {
104
- return this.step.definition(step_id);
104
+ async definition() {
105
+ return this.stepDatasource.definition();
105
106
  }
106
107
  async addStepData(link_session, identity, data) {
107
- return this.step.addStepData(link_session, identity, data);
108
+ return this.stepDatasource.addStepData(link_session, identity, data);
108
109
  }
109
110
  async getStepData(type, link_session) {
110
- return this.step.getStepData(type, link_session);
111
+ return this.stepDatasource.getStepData(type, link_session);
111
112
  }
112
113
  addVendorStat(params) {
113
- return this.step.addVendorStat(params);
114
+ return this.stepDatasource.addVendorStat(params);
114
115
  }
115
116
  future(type, id, ttl) {
116
- return this.step.future(type, id, ttl);
117
+ return this.stepDatasource.future(type, id, ttl);
117
118
  }
118
119
  milestone(type, status, success, session) {
119
- return this.step.milestone(type, status, success, session);
120
+ return this.stepDatasource.milestone(type, status, success, session);
120
121
  }
121
122
  params(extend) {
122
- return this.step.params(extend);
123
+ return this.stepDatasource.params(extend);
124
+ }
125
+ // identity(
126
+ // organization_id: string,
127
+ // instance_id: string,
128
+ // link_session: string | undefined,
129
+ // identity: IdentityDto,
130
+ // data: StepIdentityData,
131
+ // ): Promise<any> {
132
+ // return this.stepDatasource.identity(
133
+ // organization_id,
134
+ // instance_id,
135
+ // link_session,
136
+ // identity,
137
+ // data,
138
+ // );
139
+ // }
140
+ };
141
+
142
+ // src/request/context.ts
143
+ var ContextRequest = class {
144
+ constructor(contextDatasource) {
145
+ this.contextDatasource = contextDatasource;
123
146
  }
124
- identity(organization_id, instance_id, link_session, identity, data) {
125
- return this.step.identity(
126
- organization_id,
127
- instance_id,
128
- link_session,
129
- identity,
130
- data
131
- );
147
+ async params(extend) {
148
+ return this.contextDatasource.params(extend);
132
149
  }
133
150
  };
151
+
152
+ // src/index.ts
134
153
  var AppEnvironmentsSchema = import_zod.z.object({
135
154
  STAGING: import_zod.z.enum(["LOCAL", "QA", "PROD"]),
136
155
  STEP_TYPE: import_zod.z.string()
@@ -211,6 +230,7 @@ var StepContext = class {
211
230
  0 && (module.exports = {
212
231
  AutentikarRequest,
213
232
  AutentikarResponse,
233
+ ContextRequest,
214
234
  FlowContext,
215
235
  IdentitySchemaDto,
216
236
  StepContext,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autentikar/step",
3
- "version": "2.2.4",
3
+ "version": "2.2.9",
4
4
  "description": "",
5
5
  "files": [
6
6
  "dist"