@autentikar/step 2.0.0-alpha.12 → 2.0.0-alpha.14

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,16 +1,11 @@
1
+ import { StorageItem } from './index.js';
2
+ import 'file-type/core';
3
+ import 'zod';
4
+
1
5
  interface Storage {
2
6
  save(name: string, content: Buffer, instance: string): Promise<StorageItem>;
3
7
  get(key: string): Promise<StorageItem | undefined>;
4
8
  }
5
- type PersistentType = "FILESYSTEM" | "MONGODB" | "S3" | "NFS" | "S3-MRAP" | "CDN";
6
- declare class StorageItem {
7
- readonly path: string;
8
- readonly type: PersistentType;
9
- readonly buffer: Buffer;
10
- readonly fileUrl: string;
11
- constructor(path: string, type: PersistentType, buffer: Buffer, fileUrl: string);
12
- getBase64(): string;
13
- }
14
9
 
15
10
  type KVKind = "INSTANCE" | "STEP";
16
11
  interface KV {
@@ -37,4 +32,4 @@ declare let system: System;
37
32
  declare let kv: KV;
38
33
  declare let asset: Storage;
39
34
 
40
- export { type KV, type Params, type Preference, type Storage, StorageItem, type System, asset, kv, params, preference, system };
35
+ export { type KV, type Params, type Preference, type Storage, type System, asset, kv, params, preference, system };
package/dist/context.js CHANGED
@@ -20,7 +20,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/context.ts
21
21
  var context_exports = {};
22
22
  __export(context_exports, {
23
- StorageItem: () => StorageItem,
24
23
  asset: () => asset,
25
24
  kv: () => kv,
26
25
  params: () => params,
@@ -28,21 +27,6 @@ __export(context_exports, {
28
27
  system: () => system
29
28
  });
30
29
  module.exports = __toCommonJS(context_exports);
31
-
32
- // src/type/asset.ts
33
- var StorageItem = class {
34
- constructor(path, type, buffer, fileUrl) {
35
- this.path = path;
36
- this.type = type;
37
- this.buffer = buffer;
38
- this.fileUrl = fileUrl;
39
- }
40
- getBase64() {
41
- return this.buffer.toString("base64");
42
- }
43
- };
44
-
45
- // src/context.ts
46
30
  var params;
47
31
  var preference;
48
32
  var system;
@@ -50,7 +34,6 @@ var kv;
50
34
  var asset;
51
35
  // Annotate the CommonJS export names for ESM import in node:
52
36
  0 && (module.exports = {
53
- StorageItem,
54
37
  asset,
55
38
  kv,
56
39
  params,
package/dist/index.d.ts CHANGED
@@ -1,5 +1,18 @@
1
+ import * as file_type_core from 'file-type/core';
1
2
  import { z } from 'zod';
2
3
 
4
+ declare const AppEnvironmentsSchema: z.ZodObject<{
5
+ STAGING: z.ZodEnum<["LOCAL", "QA", "PROD"]>;
6
+ STEP_TYPE: z.ZodString;
7
+ }, "strip", z.ZodTypeAny, {
8
+ STAGING: "LOCAL" | "QA" | "PROD";
9
+ STEP_TYPE: string;
10
+ }, {
11
+ STAGING: "LOCAL" | "QA" | "PROD";
12
+ STEP_TYPE: string;
13
+ }>;
14
+ type AppEnvironments = z.infer<typeof AppEnvironmentsSchema>;
15
+ type Staging = AppEnvironments["STAGING"];
3
16
  type MethodContextOrganization = {
4
17
  id: string;
5
18
  };
@@ -9,8 +22,18 @@ type MethodContextFlow = {
9
22
  type MethodContextInstance = {
10
23
  id: string;
11
24
  };
25
+ type PersistentType = "FILESYSTEM" | "MONGODB" | "S3" | "NFS" | "S3-MRAP" | "CDN";
26
+ declare class StorageItem {
27
+ readonly path: string;
28
+ readonly type: PersistentType;
29
+ readonly buffer: Buffer;
30
+ readonly fileUrl: string;
31
+ constructor(path: string, type: PersistentType, buffer: Buffer, fileUrl: string);
32
+ getBase64(): string;
33
+ getContenType(): Promise<file_type_core.MimeType | "unknown">;
34
+ }
12
35
  type MethodContext = {
13
- staging: "LOCAL" | "QA" | "PROD";
36
+ staging: Staging;
14
37
  /**
15
38
  * no incluye schema (https://)
16
39
  */
@@ -20,18 +43,6 @@ type MethodContext = {
20
43
  instance: MethodContextInstance;
21
44
  };
22
45
  type Method = (req: Request, output: Record<string, string>, context: MethodContext) => Promise<unknown>;
23
- declare const AppEnvironmentsSchema: z.ZodObject<{
24
- STAGING: z.ZodEnum<["LOCAL", "QA", "PROD"]>;
25
- STEP_TYPE: z.ZodString;
26
- }, "strip", z.ZodTypeAny, {
27
- STAGING: "LOCAL" | "QA" | "PROD";
28
- STEP_TYPE: string;
29
- }, {
30
- STAGING: "LOCAL" | "QA" | "PROD";
31
- STEP_TYPE: string;
32
- }>;
33
- type AppEnvironments = z.infer<typeof AppEnvironmentsSchema>;
34
- type Staging = AppEnvironments["STAGING"];
35
46
  type AppEnv = {
36
47
  Bindings: AppEnvironments;
37
48
  Variables: {
@@ -39,4 +50,4 @@ type AppEnv = {
39
50
  };
40
51
  };
41
52
 
42
- export type { AppEnv, AppEnvironments, Method, MethodContext, MethodContextFlow, MethodContextInstance, MethodContextOrganization, Staging };
53
+ export { type AppEnv, type AppEnvironments, type Method, type MethodContext, type MethodContextFlow, type MethodContextInstance, type MethodContextOrganization, type PersistentType, type Staging, StorageItem };
package/dist/index.js CHANGED
@@ -1,8 +1,14 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
6
12
  var __copyProps = (to, from, except, desc) => {
7
13
  if (from && typeof from === "object" || typeof from === "function") {
8
14
  for (let key of __getOwnPropNames(from))
@@ -11,13 +17,51 @@ var __copyProps = (to, from, except, desc) => {
11
17
  }
12
18
  return to;
13
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
14
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
29
 
16
30
  // src/index.ts
17
31
  var src_exports = {};
32
+ __export(src_exports, {
33
+ StorageItem: () => StorageItem
34
+ });
18
35
  module.exports = __toCommonJS(src_exports);
19
36
  var import_zod = require("zod");
37
+ var import_file_type = __toESM(require("file-type"));
20
38
  var AppEnvironmentsSchema = import_zod.z.object({
21
39
  STAGING: import_zod.z.enum(["LOCAL", "QA", "PROD"]),
22
40
  STEP_TYPE: import_zod.z.string()
23
41
  });
42
+ async function getContentTypeFromBuffer(buffer) {
43
+ const type = await import_file_type.default.fromBuffer(buffer);
44
+ if (type) {
45
+ return type.mime;
46
+ } else {
47
+ return "unknown";
48
+ }
49
+ }
50
+ var StorageItem = class {
51
+ constructor(path, type, buffer, fileUrl) {
52
+ this.path = path;
53
+ this.type = type;
54
+ this.buffer = buffer;
55
+ this.fileUrl = fileUrl;
56
+ }
57
+ getBase64() {
58
+ return this.buffer.toString("base64");
59
+ }
60
+ getContenType() {
61
+ return getContentTypeFromBuffer(this.buffer);
62
+ }
63
+ };
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
66
+ StorageItem
67
+ });
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@autentikar/step",
3
- "version": "2.0.0-alpha.12",
3
+ "version": "2.0.0-alpha.14",
4
4
  "description": "",
5
5
  "files": [
6
6
  "dist"
7
7
  ],
8
8
  "exports": {
9
- ".": "./dist/index.d.ts",
9
+ ".": "./dist/index.js",
10
10
  "./context": "./dist/context.js",
11
11
  "./package.json": "./package.json"
12
12
  },
@@ -34,6 +34,7 @@
34
34
  "typescript": "^5.2.2"
35
35
  },
36
36
  "dependencies": {
37
+ "file-type": "16.5.3",
37
38
  "zod": "^3.22.4"
38
39
  }
39
40
  }