@siredvin/typed-peripheral-cloudsolutions 0.1.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.
@@ -0,0 +1,11 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__New = ____lualib.__TS__New
3
+ local ____exports = {}
4
+ local ____typed_2Dperipheral_2Dbase = require("@siredvin/typed-peripheral-base")
5
+ local IPeripheralProvider = ____typed_2Dperipheral_2Dbase.IPeripheralProvider
6
+ ____exports.crafkaBrokerPeripheralProvider = __TS__New(
7
+ IPeripheralProvider,
8
+ "crafka_broker",
9
+ function() return nil end
10
+ )
11
+ return ____exports
@@ -0,0 +1,36 @@
1
+ import { ConfigurationAPI } from "@siredvin/typed-peripheral-api/configuration";
2
+ import { IPeripheralProvider } from "@siredvin/typed-peripheral-base";
3
+
4
+ /** @noSelf **/
5
+ export interface CrafkaBroker extends ConfigurationAPI<object> {
6
+ createTopic(name: string, messageLimit?: number): Result;
7
+ listTopics(): string[];
8
+ deleteTopic(name: string): Result;
9
+ publish(topic: string, message: string): Result;
10
+ fetchMessages(topic: string, cursor: number): [number, string][];
11
+ describeTopic(topic: string): {
12
+ messageLimit: number;
13
+ firstMessage: number;
14
+ lastMessage: number;
15
+ };
16
+ subscribe(
17
+ topic: string,
18
+ options: {
19
+ fragile?: boolean;
20
+ autoCursor?: boolean;
21
+ consumerGroup?: string;
22
+ cursor?: number;
23
+ }
24
+ );
25
+ unsubscribe(topic: string);
26
+ getSubscription(topic: string): {
27
+ cursor: number;
28
+ fragile: boolean;
29
+ autoCursor: boolean;
30
+ consumerGroup?: string;
31
+ };
32
+ setCursor(topic: string, cursor: number);
33
+ }
34
+
35
+ export const crafkaBrokerPeripheralProvider =
36
+ new IPeripheralProvider<CrafkaBroker>("crafka_broker", () => null);
package/kvStorage.lua ADDED
@@ -0,0 +1,11 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__New = ____lualib.__TS__New
3
+ local ____exports = {}
4
+ local ____typed_2Dperipheral_2Dbase = require("@siredvin/typed-peripheral-base")
5
+ local IPeripheralProvider = ____typed_2Dperipheral_2Dbase.IPeripheralProvider
6
+ ____exports.kvStoragePeripheralProvider = __TS__New(
7
+ IPeripheralProvider,
8
+ "kv_storage",
9
+ function() return nil end
10
+ )
11
+ return ____exports
package/kvStorage.ts ADDED
@@ -0,0 +1,24 @@
1
+ import { ConfigurationAPI } from "@siredvin/typed-peripheral-api/configuration";
2
+ import { IPeripheralProvider } from "@siredvin/typed-peripheral-base";
3
+
4
+ /** @noSelf **/
5
+ export interface KVStorage extends ConfigurationAPI<object> {
6
+ delete(key: string): void;
7
+ put(key: string, value: string, expire?: number | null): void;
8
+ get(key: string): string | null;
9
+ mput(values: { [key: string]: string });
10
+ mget(values: string[]): LuaTable<string, string>;
11
+ list(glob?: string): string[];
12
+ get_ex(key: string): number | null;
13
+ put_ex(key: string, expire?: number | null): void;
14
+ incr(key: string, value?: number): number;
15
+ decr(key: string, value?: number): number;
16
+ subscribe(type: "changed" | "deleted", pattern: string);
17
+ unsubscribe(type: "changed" | "deleted", pattern: string);
18
+ getSubscriptions(type: "changed" | "deleted"): string[];
19
+ }
20
+
21
+ export const kvStoragePeripheralProvider = new IPeripheralProvider<KVStorage>(
22
+ "kv_storage",
23
+ () => null
24
+ );
@@ -0,0 +1,43 @@
1
+ local function __TS__New(target, ...)
2
+ local instance = setmetatable({}, target.prototype)
3
+ instance:____constructor(...)
4
+ return instance
5
+ end
6
+
7
+ local function __TS__Class(self)
8
+ local c = {prototype = {}}
9
+ c.prototype.__index = c.prototype
10
+ c.prototype.constructor = c
11
+ return c
12
+ end
13
+
14
+ local function __TS__ClassExtends(target, base)
15
+ target.____super = base
16
+ local staticMetatable = setmetatable({__index = base}, base)
17
+ setmetatable(target, staticMetatable)
18
+ local baseMetatable = getmetatable(base)
19
+ if baseMetatable then
20
+ if type(baseMetatable.__index) == "function" then
21
+ staticMetatable.__index = baseMetatable.__index
22
+ end
23
+ if type(baseMetatable.__newindex) == "function" then
24
+ staticMetatable.__newindex = baseMetatable.__newindex
25
+ end
26
+ end
27
+ setmetatable(target.prototype, base.prototype)
28
+ if type(base.prototype.__index) == "function" then
29
+ target.prototype.__index = base.prototype.__index
30
+ end
31
+ if type(base.prototype.__newindex) == "function" then
32
+ target.prototype.__newindex = base.prototype.__newindex
33
+ end
34
+ if type(base.prototype.__tostring) == "function" then
35
+ target.prototype.__tostring = base.prototype.__tostring
36
+ end
37
+ end
38
+
39
+ return {
40
+ __TS__New = __TS__New,
41
+ __TS__Class = __TS__Class,
42
+ __TS__ClassExtends = __TS__ClassExtends
43
+ }
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@siredvin/typed-peripheral-cloudsolutions",
3
+ "version": "0.1.0",
4
+ "description": "Typed peripheral library for Cloud Solutions peripherals",
5
+ "files": [
6
+ "./*.ts",
7
+ "./*.lua"
8
+ ],
9
+ "publishConfig": {
10
+ "access": "public"
11
+ },
12
+ "author": "SirEdvin",
13
+ "license": "MIT",
14
+ "scripts": {
15
+ "test": "echo \"Error: no test specified\" && exit 1",
16
+ "build": "tstl",
17
+ "clean": "rm -f *.lua",
18
+ "lint": "eslint . --ext .ts,.js",
19
+ "depcheck": "depcheck"
20
+ },
21
+ "dependencies": {
22
+ "@siredvin/cc-types": "1.1.0",
23
+ "@siredvin/craftos-types": "1.2.0",
24
+ "@siredvin/api-types": "1.1.0",
25
+ "@jackmacwindows/lua-types": "^2.13.1",
26
+ "@siredvin/typed-peripheral-base": "0.4.0",
27
+ "@siredvin/typed-peripheral-api": "0.1.0",
28
+ "@siredvin/cc-events": "*"
29
+ },
30
+ "devDependencies": {
31
+ "typescript-to-lua": "*",
32
+ "typescript": "*"
33
+ },
34
+ "nx": {
35
+ "targets": {
36
+ "lint": {
37
+ "executor": "@nx/linter:eslint",
38
+ "outputs": [
39
+ "{options.outputFile}"
40
+ ],
41
+ "options": {
42
+ "lintFilePatterns": [
43
+ "packages/typed-peripheral/**/*.{ts,tsx,js,jsx}"
44
+ ]
45
+ }
46
+ },
47
+ "depcheck": {
48
+ "executor": "nx:run-commands",
49
+ "options": {
50
+ "command": "depcheck",
51
+ "cwd": "packages/typed-peripheral"
52
+ }
53
+ }
54
+ }
55
+ }
56
+ }
@@ -0,0 +1,32 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__Class = ____lualib.__TS__Class
3
+ local __TS__New = ____lualib.__TS__New
4
+ local ____exports = {}
5
+ local ____typed_2Dperipheral_2Dbase = require("@siredvin/typed-peripheral-base")
6
+ local IPeripheralProvider = ____typed_2Dperipheral_2Dbase.IPeripheralProvider
7
+ ---
8
+ -- @noSelf *
9
+ ____exports.DummyStatsDBridge = __TS__Class()
10
+ local DummyStatsDBridge = ____exports.DummyStatsDBridge
11
+ DummyStatsDBridge.name = "DummyStatsDBridge"
12
+ function DummyStatsDBridge.prototype.____constructor(self)
13
+ end
14
+ function DummyStatsDBridge.prototype.getConfiguration()
15
+ return {}
16
+ end
17
+ function DummyStatsDBridge.prototype.count(aspect, delta)
18
+ end
19
+ function DummyStatsDBridge.prototype.delta(aspect, delta)
20
+ end
21
+ function DummyStatsDBridge.prototype.gauge(aspect, value)
22
+ end
23
+ function DummyStatsDBridge.prototype.set(aspect, eventName)
24
+ end
25
+ function DummyStatsDBridge.prototype.time(aspect, timeInMs)
26
+ end
27
+ ____exports.statsDBridgeProvider = __TS__New(
28
+ IPeripheralProvider,
29
+ "statsd_bridge",
30
+ function() return __TS__New(____exports.DummyStatsDBridge) end
31
+ )
32
+ return ____exports
@@ -0,0 +1,29 @@
1
+ import { IPeripheralProvider } from "@siredvin/typed-peripheral-base";
2
+ import { ConfigurationAPI } from "@siredvin/typed-peripheral-api/configuration";
3
+
4
+
5
+ /** @noSelf **/
6
+ export interface StatsDBridge extends ConfigurationAPI<object> {
7
+ count(aspect: String, delta: number);
8
+ delta(aspect: String, delta: number);
9
+ gauge(aspect: String, value: number);
10
+ set(aspect: String, eventName: String);
11
+ time(aspect: String, timeInMs: number);
12
+ }
13
+
14
+ /** @noSelf **/
15
+ export class DummyStatsDBridge implements StatsDBridge {
16
+ getConfiguration(): LuaTable {
17
+ return new LuaTable();
18
+ }
19
+ count(aspect: String, delta: number) {}
20
+ delta(aspect: String, delta: number) {}
21
+ gauge(aspect: String, value: number) {}
22
+ set(aspect: String, eventName: String) {}
23
+ time(aspect: String, timeInMs: number) {}
24
+ }
25
+
26
+ export const statsDBridgeProvider = new IPeripheralProvider<StatsDBridge>(
27
+ "statsd_bridge",
28
+ () => new DummyStatsDBridge()
29
+ );