@walkeros/server-core 0.1.2 → 0.2.1
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/index.d.mts +51 -18
- package/dist/index.d.ts +51 -18
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SendHeaders, SendDataValue, SendResponse, Destination as Destination$1, Elb } from '@walkeros/core';
|
|
1
|
+
import { SendHeaders, SendDataValue, SendResponse, Destination as Destination$1, Source as Source$1, Elb } from '@walkeros/core';
|
|
2
2
|
|
|
3
3
|
interface SendServerOptions {
|
|
4
4
|
headers?: SendHeaders;
|
|
@@ -9,33 +9,66 @@ declare function sendServer(url: string, data?: SendDataValue, options?: SendSer
|
|
|
9
9
|
|
|
10
10
|
declare function getHashServer(str: string, length?: number): Promise<string>;
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
type TypesGeneric$1 = Destination$1.TypesGeneric;
|
|
13
|
+
interface Destination<T extends TypesGeneric$1 = Destination$1.Types> extends Destination$1.Instance<T> {
|
|
13
14
|
}
|
|
14
|
-
type Init = Destination$1.Init;
|
|
15
|
-
type Config<
|
|
16
|
-
type PartialConfig<
|
|
17
|
-
type InitFn<
|
|
18
|
-
type PushFn<
|
|
15
|
+
type Init$1 = Destination$1.Init;
|
|
16
|
+
type Config$1<T extends TypesGeneric$1 = Destination$1.Types> = Destination$1.Config<T>;
|
|
17
|
+
type PartialConfig$1<T extends TypesGeneric$1 = Destination$1.Types> = Destination$1.PartialConfig<T>;
|
|
18
|
+
type InitFn<T extends TypesGeneric$1 = Destination$1.Types> = Destination$1.InitFn<T>;
|
|
19
|
+
type PushFn<T extends TypesGeneric$1 = Destination$1.Types> = Destination$1.PushFn<T>;
|
|
19
20
|
type PushEvent<Mapping = unknown> = Destination$1.PushEvent<Mapping>;
|
|
20
21
|
type PushEvents<Mapping = unknown> = Destination$1.PushEvents<Mapping>;
|
|
22
|
+
/**
|
|
23
|
+
* Server-specific environment requirements interface
|
|
24
|
+
*
|
|
25
|
+
* Extends the core Env interface for server-side destinations.
|
|
26
|
+
* Used for dependency injection of SDK classes and external APIs.
|
|
27
|
+
*/
|
|
28
|
+
interface Env$1 extends Destination$1.Env {
|
|
29
|
+
}
|
|
21
30
|
|
|
22
|
-
type
|
|
23
|
-
type
|
|
24
|
-
type destination_Init = Init;
|
|
25
|
-
type destination_InitFn<Settings = unknown, Mapping = unknown> = InitFn<Settings, Mapping>;
|
|
26
|
-
type destination_PartialConfig<Settings = unknown, Mapping = unknown> = PartialConfig<Settings, Mapping>;
|
|
31
|
+
type destination_Destination<T extends TypesGeneric$1 = Destination$1.Types> = Destination<T>;
|
|
32
|
+
type destination_InitFn<T extends TypesGeneric$1 = Destination$1.Types> = InitFn<T>;
|
|
27
33
|
type destination_PushEvent<Mapping = unknown> = PushEvent<Mapping>;
|
|
28
34
|
type destination_PushEvents<Mapping = unknown> = PushEvents<Mapping>;
|
|
29
|
-
type destination_PushFn<
|
|
35
|
+
type destination_PushFn<T extends TypesGeneric$1 = Destination$1.Types> = PushFn<T>;
|
|
30
36
|
declare namespace destination {
|
|
31
|
-
export type {
|
|
37
|
+
export type { Config$1 as Config, destination_Destination as Destination, Env$1 as Env, Init$1 as Init, destination_InitFn as InitFn, PartialConfig$1 as PartialConfig, destination_PushEvent as PushEvent, destination_PushEvents as PushEvents, destination_PushFn as PushFn, TypesGeneric$1 as TypesGeneric };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type TypesGeneric = Source$1.TypesGeneric;
|
|
41
|
+
interface Source<T extends TypesGeneric = Source$1.Types> extends Source$1.Instance<T> {
|
|
42
|
+
}
|
|
43
|
+
type Config<T extends TypesGeneric = Source$1.Types> = Source$1.Config<T>;
|
|
44
|
+
type PartialConfig<T extends TypesGeneric = Source$1.Types> = Source$1.PartialConfig<T>;
|
|
45
|
+
type Init<T extends TypesGeneric = Source$1.Types> = Source$1.Init<T>;
|
|
46
|
+
type InitSource<T extends TypesGeneric = Source$1.Types> = Source$1.InitSource<T>;
|
|
47
|
+
/**
|
|
48
|
+
* Server-specific environment requirements interface
|
|
49
|
+
*
|
|
50
|
+
* Extends the core BaseEnv interface for server-side sources.
|
|
51
|
+
* Used for dependency injection of SDK classes and external APIs.
|
|
52
|
+
*/
|
|
53
|
+
interface Env extends Source$1.BaseEnv {
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
type source_Config<T extends TypesGeneric = Source$1.Types> = Config<T>;
|
|
57
|
+
type source_Env = Env;
|
|
58
|
+
type source_Init<T extends TypesGeneric = Source$1.Types> = Init<T>;
|
|
59
|
+
type source_InitSource<T extends TypesGeneric = Source$1.Types> = InitSource<T>;
|
|
60
|
+
type source_PartialConfig<T extends TypesGeneric = Source$1.Types> = PartialConfig<T>;
|
|
61
|
+
type source_Source<T extends TypesGeneric = Source$1.Types> = Source<T>;
|
|
62
|
+
type source_TypesGeneric = TypesGeneric;
|
|
63
|
+
declare namespace source {
|
|
64
|
+
export type { source_Config as Config, source_Env as Env, source_Init as Init, source_InitSource as InitSource, source_PartialConfig as PartialConfig, source_Source as Source, source_TypesGeneric as TypesGeneric };
|
|
32
65
|
}
|
|
33
66
|
|
|
34
67
|
type Fn<R = Return> = Elb.Fn<R> & CommandDestination<R> & CommandRun<R>;
|
|
35
|
-
type CommandDestination<R = void> = (event: 'walker destination', destination: Destination | Init, config?: Config) => R;
|
|
68
|
+
type CommandDestination<R = void> = (event: 'walker destination', destination: Destination | Init$1, config?: Config$1) => R;
|
|
36
69
|
type CommandRun<R = void> = (event: 'walker run') => R;
|
|
37
|
-
type PushData = Elb.PushData | Destination | Init;
|
|
38
|
-
type PushOptions = Config;
|
|
70
|
+
type PushData = Elb.PushData | Destination | Init$1;
|
|
71
|
+
type PushOptions = Config$1;
|
|
39
72
|
type PushResult = Elb.PushResult;
|
|
40
73
|
type Return<R = Promise<PushResult>> = R;
|
|
41
74
|
|
|
@@ -50,4 +83,4 @@ declare namespace elb {
|
|
|
50
83
|
export type { elb_CommandDestination as CommandDestination, elb_CommandRun as CommandRun, elb_Fn as Fn, elb_PushData as PushData, elb_PushOptions as PushOptions, elb_PushResult as PushResult, elb_Return as Return };
|
|
51
84
|
}
|
|
52
85
|
|
|
53
|
-
export { destination as DestinationServer, elb as Elb, type SendServerOptions, getHashServer, sendServer };
|
|
86
|
+
export { destination as DestinationServer, elb as Elb, type SendServerOptions, source as SourceServer, getHashServer, sendServer };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SendHeaders, SendDataValue, SendResponse, Destination as Destination$1, Elb } from '@walkeros/core';
|
|
1
|
+
import { SendHeaders, SendDataValue, SendResponse, Destination as Destination$1, Source as Source$1, Elb } from '@walkeros/core';
|
|
2
2
|
|
|
3
3
|
interface SendServerOptions {
|
|
4
4
|
headers?: SendHeaders;
|
|
@@ -9,33 +9,66 @@ declare function sendServer(url: string, data?: SendDataValue, options?: SendSer
|
|
|
9
9
|
|
|
10
10
|
declare function getHashServer(str: string, length?: number): Promise<string>;
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
type TypesGeneric$1 = Destination$1.TypesGeneric;
|
|
13
|
+
interface Destination<T extends TypesGeneric$1 = Destination$1.Types> extends Destination$1.Instance<T> {
|
|
13
14
|
}
|
|
14
|
-
type Init = Destination$1.Init;
|
|
15
|
-
type Config<
|
|
16
|
-
type PartialConfig<
|
|
17
|
-
type InitFn<
|
|
18
|
-
type PushFn<
|
|
15
|
+
type Init$1 = Destination$1.Init;
|
|
16
|
+
type Config$1<T extends TypesGeneric$1 = Destination$1.Types> = Destination$1.Config<T>;
|
|
17
|
+
type PartialConfig$1<T extends TypesGeneric$1 = Destination$1.Types> = Destination$1.PartialConfig<T>;
|
|
18
|
+
type InitFn<T extends TypesGeneric$1 = Destination$1.Types> = Destination$1.InitFn<T>;
|
|
19
|
+
type PushFn<T extends TypesGeneric$1 = Destination$1.Types> = Destination$1.PushFn<T>;
|
|
19
20
|
type PushEvent<Mapping = unknown> = Destination$1.PushEvent<Mapping>;
|
|
20
21
|
type PushEvents<Mapping = unknown> = Destination$1.PushEvents<Mapping>;
|
|
22
|
+
/**
|
|
23
|
+
* Server-specific environment requirements interface
|
|
24
|
+
*
|
|
25
|
+
* Extends the core Env interface for server-side destinations.
|
|
26
|
+
* Used for dependency injection of SDK classes and external APIs.
|
|
27
|
+
*/
|
|
28
|
+
interface Env$1 extends Destination$1.Env {
|
|
29
|
+
}
|
|
21
30
|
|
|
22
|
-
type
|
|
23
|
-
type
|
|
24
|
-
type destination_Init = Init;
|
|
25
|
-
type destination_InitFn<Settings = unknown, Mapping = unknown> = InitFn<Settings, Mapping>;
|
|
26
|
-
type destination_PartialConfig<Settings = unknown, Mapping = unknown> = PartialConfig<Settings, Mapping>;
|
|
31
|
+
type destination_Destination<T extends TypesGeneric$1 = Destination$1.Types> = Destination<T>;
|
|
32
|
+
type destination_InitFn<T extends TypesGeneric$1 = Destination$1.Types> = InitFn<T>;
|
|
27
33
|
type destination_PushEvent<Mapping = unknown> = PushEvent<Mapping>;
|
|
28
34
|
type destination_PushEvents<Mapping = unknown> = PushEvents<Mapping>;
|
|
29
|
-
type destination_PushFn<
|
|
35
|
+
type destination_PushFn<T extends TypesGeneric$1 = Destination$1.Types> = PushFn<T>;
|
|
30
36
|
declare namespace destination {
|
|
31
|
-
export type {
|
|
37
|
+
export type { Config$1 as Config, destination_Destination as Destination, Env$1 as Env, Init$1 as Init, destination_InitFn as InitFn, PartialConfig$1 as PartialConfig, destination_PushEvent as PushEvent, destination_PushEvents as PushEvents, destination_PushFn as PushFn, TypesGeneric$1 as TypesGeneric };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type TypesGeneric = Source$1.TypesGeneric;
|
|
41
|
+
interface Source<T extends TypesGeneric = Source$1.Types> extends Source$1.Instance<T> {
|
|
42
|
+
}
|
|
43
|
+
type Config<T extends TypesGeneric = Source$1.Types> = Source$1.Config<T>;
|
|
44
|
+
type PartialConfig<T extends TypesGeneric = Source$1.Types> = Source$1.PartialConfig<T>;
|
|
45
|
+
type Init<T extends TypesGeneric = Source$1.Types> = Source$1.Init<T>;
|
|
46
|
+
type InitSource<T extends TypesGeneric = Source$1.Types> = Source$1.InitSource<T>;
|
|
47
|
+
/**
|
|
48
|
+
* Server-specific environment requirements interface
|
|
49
|
+
*
|
|
50
|
+
* Extends the core BaseEnv interface for server-side sources.
|
|
51
|
+
* Used for dependency injection of SDK classes and external APIs.
|
|
52
|
+
*/
|
|
53
|
+
interface Env extends Source$1.BaseEnv {
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
type source_Config<T extends TypesGeneric = Source$1.Types> = Config<T>;
|
|
57
|
+
type source_Env = Env;
|
|
58
|
+
type source_Init<T extends TypesGeneric = Source$1.Types> = Init<T>;
|
|
59
|
+
type source_InitSource<T extends TypesGeneric = Source$1.Types> = InitSource<T>;
|
|
60
|
+
type source_PartialConfig<T extends TypesGeneric = Source$1.Types> = PartialConfig<T>;
|
|
61
|
+
type source_Source<T extends TypesGeneric = Source$1.Types> = Source<T>;
|
|
62
|
+
type source_TypesGeneric = TypesGeneric;
|
|
63
|
+
declare namespace source {
|
|
64
|
+
export type { source_Config as Config, source_Env as Env, source_Init as Init, source_InitSource as InitSource, source_PartialConfig as PartialConfig, source_Source as Source, source_TypesGeneric as TypesGeneric };
|
|
32
65
|
}
|
|
33
66
|
|
|
34
67
|
type Fn<R = Return> = Elb.Fn<R> & CommandDestination<R> & CommandRun<R>;
|
|
35
|
-
type CommandDestination<R = void> = (event: 'walker destination', destination: Destination | Init, config?: Config) => R;
|
|
68
|
+
type CommandDestination<R = void> = (event: 'walker destination', destination: Destination | Init$1, config?: Config$1) => R;
|
|
36
69
|
type CommandRun<R = void> = (event: 'walker run') => R;
|
|
37
|
-
type PushData = Elb.PushData | Destination | Init;
|
|
38
|
-
type PushOptions = Config;
|
|
70
|
+
type PushData = Elb.PushData | Destination | Init$1;
|
|
71
|
+
type PushOptions = Config$1;
|
|
39
72
|
type PushResult = Elb.PushResult;
|
|
40
73
|
type Return<R = Promise<PushResult>> = R;
|
|
41
74
|
|
|
@@ -50,4 +83,4 @@ declare namespace elb {
|
|
|
50
83
|
export type { elb_CommandDestination as CommandDestination, elb_CommandRun as CommandRun, elb_Fn as Fn, elb_PushData as PushData, elb_PushOptions as PushOptions, elb_PushResult as PushResult, elb_Return as Return };
|
|
51
84
|
}
|
|
52
85
|
|
|
53
|
-
export { destination as DestinationServer, elb as Elb, type SendServerOptions, getHashServer, sendServer };
|
|
86
|
+
export { destination as DestinationServer, elb as Elb, type SendServerOptions, source as SourceServer, getHashServer, sendServer };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,t=Object.create,r=Object.defineProperty,o=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,a=Object.getPrototypeOf,n=Object.prototype.hasOwnProperty,u=(e,t,a,u)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let c of s(t))n.call(e,c)||c===a||r(e,c,{get:()=>t[c],enumerable:!(u=o(t,c))||u.enumerable});return e},c=(e,o,s)=>(s=null!=e?t(a(e)):{},u(!o&&e&&e.__esModule?s:r(s,"default",{value:e,enumerable:!0}),e)),i={};((e,t)=>{for(var o in t)r(e,o,{get:t[o],enumerable:!0})})(i,{DestinationServer:()=>y,Elb:()=>b,getHashServer:()=>h,sendServer:()=>f}),module.exports=(e=i,u(r({},"__esModule",{value:!0}),e));var d=require("@walkeros/core"),l=c(require("http")),p=c(require("https"));function f(e,t,r={}){const o=(0,d.getHeaders)(r.headers),s=(0,d.transformData)(t),a=r.method||"POST",n=r.timeout||5e3;return new Promise(t=>{const r=new URL(e),u="https:"===r.protocol?p:l,c={method:a,headers:o},i=u.request(r,c,e=>{const r=[];e.on("data",e=>{r.push(e)}),e.on("end",()=>{const o=!!(e.statusCode&&e.statusCode>=200&&e.statusCode<300),s=Buffer.concat(r).toString(),a=(0,d.tryCatch)(JSON.parse,()=>s)(s);t({ok:o,data:a,error:o?void 0:`${e.statusCode} ${e.statusMessage}`})})});i.on("error",e=>{t({ok:!1,error:e.message})}),i.on("timeout",()=>{i.destroy(),t({ok:!1,error:"Request timeout"})}),i.setTimeout(n),s&&i.write(s),i.end()})}var m=require("crypto");async function h(e,t){return(await async function(e){const t=(0,m.createHash)("sha256");return t.update(e),t.digest("hex")}(e)).slice(0,t)}var y={},b={};//# sourceMappingURL=index.js.map
|
|
1
|
+
"use strict";var e,t=Object.create,r=Object.defineProperty,o=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,a=Object.getPrototypeOf,n=Object.prototype.hasOwnProperty,u=(e,t,a,u)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let c of s(t))n.call(e,c)||c===a||r(e,c,{get:()=>t[c],enumerable:!(u=o(t,c))||u.enumerable});return e},c=(e,o,s)=>(s=null!=e?t(a(e)):{},u(!o&&e&&e.__esModule?s:r(s,"default",{value:e,enumerable:!0}),e)),i={};((e,t)=>{for(var o in t)r(e,o,{get:t[o],enumerable:!0})})(i,{DestinationServer:()=>y,Elb:()=>v,SourceServer:()=>b,getHashServer:()=>h,sendServer:()=>f}),module.exports=(e=i,u(r({},"__esModule",{value:!0}),e));var d=require("@walkeros/core"),l=c(require("http")),p=c(require("https"));function f(e,t,r={}){const o=(0,d.getHeaders)(r.headers),s=(0,d.transformData)(t),a=r.method||"POST",n=r.timeout||5e3;return new Promise(t=>{const r=new URL(e),u="https:"===r.protocol?p:l,c={method:a,headers:o},i=u.request(r,c,e=>{const r=[];e.on("data",e=>{r.push(e)}),e.on("end",()=>{const o=!!(e.statusCode&&e.statusCode>=200&&e.statusCode<300),s=Buffer.concat(r).toString(),a=(0,d.tryCatch)(JSON.parse,()=>s)(s);t({ok:o,data:a,error:o?void 0:`${e.statusCode} ${e.statusMessage}`})})});i.on("error",e=>{t({ok:!1,error:e.message})}),i.on("timeout",()=>{i.destroy(),t({ok:!1,error:"Request timeout"})}),i.setTimeout(n),s&&i.write(s),i.end()})}var m=require("crypto");async function h(e,t){return(await async function(e){const t=(0,m.createHash)("sha256");return t.update(e),t.digest("hex")}(e)).slice(0,t)}var y={},b={},v={};//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/sendServer.ts","../src/getHashServer.ts","../src/types/destination.ts","../src/types/elb.ts"],"sourcesContent":["// Export server-specific utilities\nexport * from './sendServer';\nexport * from './getHashServer';\n\n// Export server-specific types\nexport * from './types';\n","import type { SendDataValue, SendHeaders, SendResponse } from '@walkeros/core';\nimport { getHeaders, transformData, tryCatch } from '@walkeros/core';\nimport * as http from 'http';\nimport * as https from 'https';\n\nexport interface SendServerOptions {\n headers?: SendHeaders;\n method?: string;\n timeout?: number;\n}\n\nexport function sendServer(\n url: string,\n data?: SendDataValue,\n options: SendServerOptions = {},\n): Promise<SendResponse> {\n const headers = getHeaders(options.headers);\n const body = transformData(data);\n const method = options.method || 'POST';\n const timeout = options.timeout || 5000;\n\n return new Promise((resolve) => {\n const urlObj = new URL(url);\n const lib = urlObj.protocol === 'https:' ? https : http;\n const options: http.RequestOptions | https.RequestOptions = {\n method,\n headers,\n };\n\n const req = lib.request(urlObj, options, (res) => {\n const chunks: Uint8Array[] = [];\n\n res.on('data', (chunk) => {\n chunks.push(chunk);\n });\n\n res.on('end', () => {\n const ok = !!(\n res.statusCode &&\n res.statusCode >= 200 &&\n res.statusCode < 300\n );\n\n const responseData = Buffer.concat(chunks).toString();\n const parsedData = tryCatch(\n JSON.parse,\n () => responseData,\n )(responseData);\n\n resolve({\n ok,\n data: parsedData,\n error: ok ? undefined : `${res.statusCode} ${res.statusMessage}`,\n });\n });\n });\n\n req.on('error', (error) => {\n resolve({\n ok: false,\n error: error.message,\n });\n });\n\n req.on('timeout', () => {\n req.destroy();\n resolve({\n ok: false,\n error: 'Request timeout',\n });\n });\n\n req.setTimeout(timeout);\n\n if (body) req.write(body);\n\n req.end();\n });\n}\n","import { createHash } from 'crypto';\n\nasync function sha256(message: string): Promise<string> {\n const hash = createHash('sha256');\n hash.update(message);\n return hash.digest('hex');\n}\n\nexport async function getHashServer(\n str: string,\n length?: number,\n): Promise<string> {\n return (await sha256(str)).slice(0, length);\n}\n","
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/sendServer.ts","../src/getHashServer.ts","../src/types/destination.ts","../src/types/source.ts","../src/types/elb.ts"],"sourcesContent":["// Export server-specific utilities\nexport * from './sendServer';\nexport * from './getHashServer';\n\n// Export server-specific types\nexport * from './types';\n","import type { SendDataValue, SendHeaders, SendResponse } from '@walkeros/core';\nimport { getHeaders, transformData, tryCatch } from '@walkeros/core';\nimport * as http from 'http';\nimport * as https from 'https';\n\nexport interface SendServerOptions {\n headers?: SendHeaders;\n method?: string;\n timeout?: number;\n}\n\nexport function sendServer(\n url: string,\n data?: SendDataValue,\n options: SendServerOptions = {},\n): Promise<SendResponse> {\n const headers = getHeaders(options.headers);\n const body = transformData(data);\n const method = options.method || 'POST';\n const timeout = options.timeout || 5000;\n\n return new Promise((resolve) => {\n const urlObj = new URL(url);\n const lib = urlObj.protocol === 'https:' ? https : http;\n const options: http.RequestOptions | https.RequestOptions = {\n method,\n headers,\n };\n\n const req = lib.request(urlObj, options, (res) => {\n const chunks: Uint8Array[] = [];\n\n res.on('data', (chunk) => {\n chunks.push(chunk);\n });\n\n res.on('end', () => {\n const ok = !!(\n res.statusCode &&\n res.statusCode >= 200 &&\n res.statusCode < 300\n );\n\n const responseData = Buffer.concat(chunks).toString();\n const parsedData = tryCatch(\n JSON.parse,\n () => responseData,\n )(responseData);\n\n resolve({\n ok,\n data: parsedData,\n error: ok ? undefined : `${res.statusCode} ${res.statusMessage}`,\n });\n });\n });\n\n req.on('error', (error) => {\n resolve({\n ok: false,\n error: error.message,\n });\n });\n\n req.on('timeout', () => {\n req.destroy();\n resolve({\n ok: false,\n error: 'Request timeout',\n });\n });\n\n req.setTimeout(timeout);\n\n if (body) req.write(body);\n\n req.end();\n });\n}\n","import { createHash } from 'crypto';\n\nasync function sha256(message: string): Promise<string> {\n const hash = createHash('sha256');\n hash.update(message);\n return hash.digest('hex');\n}\n\nexport async function getHashServer(\n str: string,\n length?: number,\n): Promise<string> {\n return (await sha256(str)).slice(0, length);\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Destination as WalkerOSDestination } from '@walkeros/core';\n\nexport type TypesGeneric = WalkerOSDestination.TypesGeneric;\n\nexport interface Destination<T extends TypesGeneric = WalkerOSDestination.Types>\n extends WalkerOSDestination.Instance<T> {}\n\nexport type Init = WalkerOSDestination.Init;\n\nexport type Config<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.Config<T>;\n\nexport type PartialConfig<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.PartialConfig<T>;\n\nexport type InitFn<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.InitFn<T>;\n\nexport type PushFn<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.PushFn<T>;\n\nexport type PushEvent<Mapping = unknown> =\n WalkerOSDestination.PushEvent<Mapping>;\n\nexport type PushEvents<Mapping = unknown> =\n WalkerOSDestination.PushEvents<Mapping>;\n\n/**\n * Server-specific environment requirements interface\n *\n * Extends the core Env interface for server-side destinations.\n * Used for dependency injection of SDK classes and external APIs.\n */\nexport interface Env extends WalkerOSDestination.Env {\n // Server environments can include SDK constructors, API clients, etc.\n // Each destination extends this further with specific requirements\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Source as WalkerOSSource } from '@walkeros/core';\n\nexport type TypesGeneric = WalkerOSSource.TypesGeneric;\n\nexport interface Source<T extends TypesGeneric = WalkerOSSource.Types>\n extends WalkerOSSource.Instance<T> {}\n\nexport type Config<T extends TypesGeneric = WalkerOSSource.Types> =\n WalkerOSSource.Config<T>;\n\nexport type PartialConfig<T extends TypesGeneric = WalkerOSSource.Types> =\n WalkerOSSource.PartialConfig<T>;\n\nexport type Init<T extends TypesGeneric = WalkerOSSource.Types> =\n WalkerOSSource.Init<T>;\n\nexport type InitSource<T extends TypesGeneric = WalkerOSSource.Types> =\n WalkerOSSource.InitSource<T>;\n\n/**\n * Server-specific environment requirements interface\n *\n * Extends the core BaseEnv interface for server-side sources.\n * Used for dependency injection of SDK classes and external APIs.\n */\nexport interface Env extends WalkerOSSource.BaseEnv {\n // Server environments can include SDK constructors, API clients, etc.\n // Each source extends this further with specific requirements\n}\n","import type { Elb } from '@walkeros/core';\nimport type { Destination, Init, Config } from './destination';\n\nexport type Fn<R = Return> = Elb.Fn<R> & CommandDestination<R> & CommandRun<R>;\n\nexport type CommandDestination<R = void> = (\n event: 'walker destination',\n destination: Destination | Init,\n config?: Config,\n) => R;\n\nexport type CommandRun<R = void> = (event: 'walker run') => R;\n\nexport type PushData = Elb.PushData | Destination | Init;\n\nexport type PushOptions = Config;\n\nexport type PushResult = Elb.PushResult;\n\nexport type Return<R = Promise<PushResult>> = R;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,kBAAoD;AACpD,WAAsB;AACtB,YAAuB;AAQhB,SAAS,WACd,KACA,MACA,UAA6B,CAAC,GACP;AACvB,QAAM,cAAU,wBAAW,QAAQ,OAAO;AAC1C,QAAM,WAAO,2BAAc,IAAI;AAC/B,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,UAAU,QAAQ,WAAW;AAEnC,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,UAAM,SAAS,IAAI,IAAI,GAAG;AAC1B,UAAM,MAAM,OAAO,aAAa,WAAW,QAAQ;AACnD,UAAMA,WAAsD;AAAA,MAC1D;AAAA,MACA;AAAA,IACF;AAEA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Data as e,tryCatch as o}from"@walkeros/core";import*as r from"http";import*as s from"https";function a(a,n,
|
|
1
|
+
import{getHeaders as t,transformData as e,tryCatch as o}from"@walkeros/core";import*as r from"http";import*as s from"https";function a(a,n,u={}){const i=t(u.headers),c=e(n),d=u.method||"POST",m=u.timeout||5e3;return new Promise(t=>{const e=new URL(a),n="https:"===e.protocol?s:r,u={method:d,headers:i},p=n.request(e,u,e=>{const r=[];e.on("data",t=>{r.push(t)}),e.on("end",()=>{const s=!!(e.statusCode&&e.statusCode>=200&&e.statusCode<300),a=Buffer.concat(r).toString(),n=o(JSON.parse,()=>a)(a);t({ok:s,data:n,error:s?void 0:`${e.statusCode} ${e.statusMessage}`})})});p.on("error",e=>{t({ok:!1,error:e.message})}),p.on("timeout",()=>{p.destroy(),t({ok:!1,error:"Request timeout"})}),p.setTimeout(m),c&&p.write(c),p.end()})}import{createHash as n}from"crypto";async function u(t,e){return(await async function(t){const e=n("sha256");return e.update(t),e.digest("hex")}(t)).slice(0,e)}var i={},c={},d={};export{i as DestinationServer,d as Elb,c as SourceServer,u as getHashServer,a as sendServer};//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/sendServer.ts","../src/getHashServer.ts","../src/types/destination.ts","../src/types/elb.ts"],"sourcesContent":["import type { SendDataValue, SendHeaders, SendResponse } from '@walkeros/core';\nimport { getHeaders, transformData, tryCatch } from '@walkeros/core';\nimport * as http from 'http';\nimport * as https from 'https';\n\nexport interface SendServerOptions {\n headers?: SendHeaders;\n method?: string;\n timeout?: number;\n}\n\nexport function sendServer(\n url: string,\n data?: SendDataValue,\n options: SendServerOptions = {},\n): Promise<SendResponse> {\n const headers = getHeaders(options.headers);\n const body = transformData(data);\n const method = options.method || 'POST';\n const timeout = options.timeout || 5000;\n\n return new Promise((resolve) => {\n const urlObj = new URL(url);\n const lib = urlObj.protocol === 'https:' ? https : http;\n const options: http.RequestOptions | https.RequestOptions = {\n method,\n headers,\n };\n\n const req = lib.request(urlObj, options, (res) => {\n const chunks: Uint8Array[] = [];\n\n res.on('data', (chunk) => {\n chunks.push(chunk);\n });\n\n res.on('end', () => {\n const ok = !!(\n res.statusCode &&\n res.statusCode >= 200 &&\n res.statusCode < 300\n );\n\n const responseData = Buffer.concat(chunks).toString();\n const parsedData = tryCatch(\n JSON.parse,\n () => responseData,\n )(responseData);\n\n resolve({\n ok,\n data: parsedData,\n error: ok ? undefined : `${res.statusCode} ${res.statusMessage}`,\n });\n });\n });\n\n req.on('error', (error) => {\n resolve({\n ok: false,\n error: error.message,\n });\n });\n\n req.on('timeout', () => {\n req.destroy();\n resolve({\n ok: false,\n error: 'Request timeout',\n });\n });\n\n req.setTimeout(timeout);\n\n if (body) req.write(body);\n\n req.end();\n });\n}\n","import { createHash } from 'crypto';\n\nasync function sha256(message: string): Promise<string> {\n const hash = createHash('sha256');\n hash.update(message);\n return hash.digest('hex');\n}\n\nexport async function getHashServer(\n str: string,\n length?: number,\n): Promise<string> {\n return (await sha256(str)).slice(0, length);\n}\n","
|
|
1
|
+
{"version":3,"sources":["../src/sendServer.ts","../src/getHashServer.ts","../src/types/destination.ts","../src/types/source.ts","../src/types/elb.ts"],"sourcesContent":["import type { SendDataValue, SendHeaders, SendResponse } from '@walkeros/core';\nimport { getHeaders, transformData, tryCatch } from '@walkeros/core';\nimport * as http from 'http';\nimport * as https from 'https';\n\nexport interface SendServerOptions {\n headers?: SendHeaders;\n method?: string;\n timeout?: number;\n}\n\nexport function sendServer(\n url: string,\n data?: SendDataValue,\n options: SendServerOptions = {},\n): Promise<SendResponse> {\n const headers = getHeaders(options.headers);\n const body = transformData(data);\n const method = options.method || 'POST';\n const timeout = options.timeout || 5000;\n\n return new Promise((resolve) => {\n const urlObj = new URL(url);\n const lib = urlObj.protocol === 'https:' ? https : http;\n const options: http.RequestOptions | https.RequestOptions = {\n method,\n headers,\n };\n\n const req = lib.request(urlObj, options, (res) => {\n const chunks: Uint8Array[] = [];\n\n res.on('data', (chunk) => {\n chunks.push(chunk);\n });\n\n res.on('end', () => {\n const ok = !!(\n res.statusCode &&\n res.statusCode >= 200 &&\n res.statusCode < 300\n );\n\n const responseData = Buffer.concat(chunks).toString();\n const parsedData = tryCatch(\n JSON.parse,\n () => responseData,\n )(responseData);\n\n resolve({\n ok,\n data: parsedData,\n error: ok ? undefined : `${res.statusCode} ${res.statusMessage}`,\n });\n });\n });\n\n req.on('error', (error) => {\n resolve({\n ok: false,\n error: error.message,\n });\n });\n\n req.on('timeout', () => {\n req.destroy();\n resolve({\n ok: false,\n error: 'Request timeout',\n });\n });\n\n req.setTimeout(timeout);\n\n if (body) req.write(body);\n\n req.end();\n });\n}\n","import { createHash } from 'crypto';\n\nasync function sha256(message: string): Promise<string> {\n const hash = createHash('sha256');\n hash.update(message);\n return hash.digest('hex');\n}\n\nexport async function getHashServer(\n str: string,\n length?: number,\n): Promise<string> {\n return (await sha256(str)).slice(0, length);\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Destination as WalkerOSDestination } from '@walkeros/core';\n\nexport type TypesGeneric = WalkerOSDestination.TypesGeneric;\n\nexport interface Destination<T extends TypesGeneric = WalkerOSDestination.Types>\n extends WalkerOSDestination.Instance<T> {}\n\nexport type Init = WalkerOSDestination.Init;\n\nexport type Config<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.Config<T>;\n\nexport type PartialConfig<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.PartialConfig<T>;\n\nexport type InitFn<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.InitFn<T>;\n\nexport type PushFn<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.PushFn<T>;\n\nexport type PushEvent<Mapping = unknown> =\n WalkerOSDestination.PushEvent<Mapping>;\n\nexport type PushEvents<Mapping = unknown> =\n WalkerOSDestination.PushEvents<Mapping>;\n\n/**\n * Server-specific environment requirements interface\n *\n * Extends the core Env interface for server-side destinations.\n * Used for dependency injection of SDK classes and external APIs.\n */\nexport interface Env extends WalkerOSDestination.Env {\n // Server environments can include SDK constructors, API clients, etc.\n // Each destination extends this further with specific requirements\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Source as WalkerOSSource } from '@walkeros/core';\n\nexport type TypesGeneric = WalkerOSSource.TypesGeneric;\n\nexport interface Source<T extends TypesGeneric = WalkerOSSource.Types>\n extends WalkerOSSource.Instance<T> {}\n\nexport type Config<T extends TypesGeneric = WalkerOSSource.Types> =\n WalkerOSSource.Config<T>;\n\nexport type PartialConfig<T extends TypesGeneric = WalkerOSSource.Types> =\n WalkerOSSource.PartialConfig<T>;\n\nexport type Init<T extends TypesGeneric = WalkerOSSource.Types> =\n WalkerOSSource.Init<T>;\n\nexport type InitSource<T extends TypesGeneric = WalkerOSSource.Types> =\n WalkerOSSource.InitSource<T>;\n\n/**\n * Server-specific environment requirements interface\n *\n * Extends the core BaseEnv interface for server-side sources.\n * Used for dependency injection of SDK classes and external APIs.\n */\nexport interface Env extends WalkerOSSource.BaseEnv {\n // Server environments can include SDK constructors, API clients, etc.\n // Each source extends this further with specific requirements\n}\n","import type { Elb } from '@walkeros/core';\nimport type { Destination, Init, Config } from './destination';\n\nexport type Fn<R = Return> = Elb.Fn<R> & CommandDestination<R> & CommandRun<R>;\n\nexport type CommandDestination<R = void> = (\n event: 'walker destination',\n destination: Destination | Init,\n config?: Config,\n) => R;\n\nexport type CommandRun<R = void> = (event: 'walker run') => R;\n\nexport type PushData = Elb.PushData | Destination | Init;\n\nexport type PushOptions = Config;\n\nexport type PushResult = Elb.PushResult;\n\nexport type Return<R = Promise<PushResult>> = R;\n"],"mappings":";AACA,SAAS,YAAY,eAAe,gBAAgB;AACpD,YAAY,UAAU;AACtB,YAAY,WAAW;AAQhB,SAAS,WACd,KACA,MACA,UAA6B,CAAC,GACP;AACvB,QAAM,UAAU,WAAW,QAAQ,OAAO;AAC1C,QAAM,OAAO,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;AAChC,OAAK,OAAO,OAAO;AACnB,SAAO,KAAK,OAAO,KAAK;AAC1B;AAEA,eAAsB,cACpB,KACA,QACiB;AACjB,UAAQ,MAAM,OAAO,GAAG,GAAG,MAAM,GAAG,MAAM;AAC5C;;;ACbA;;;ACAA;;;ACAA;","names":["options"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@walkeros/server-core",
|
|
3
3
|
"description": "Server-specific utilities for walkerOS",
|
|
4
|
-
"version": "0.1
|
|
4
|
+
"version": "0.2.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.mjs",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"update": "npx npm-check-updates -u && npm update"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@walkeros/core": "0.1
|
|
28
|
+
"@walkeros/core": "0.2.1"
|
|
29
29
|
},
|
|
30
30
|
"repository": {
|
|
31
31
|
"url": "git+https://github.com/elbwalker/walkerOS.git",
|