polyapi 0.1.50 → 0.1.51
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.
|
@@ -14,11 +14,7 @@ module.exports = (clientID, getSocket) => {
|
|
|
14
14
|
set(variableHandlers, path, {
|
|
15
15
|
get: () => {
|
|
16
16
|
if (secret) {
|
|
17
|
-
return Promise.resolve(
|
|
18
|
-
type: 'PolySecretVariable',
|
|
19
|
-
id,
|
|
20
|
-
secret
|
|
21
|
-
});
|
|
17
|
+
return Promise.resolve('*** variable is secret ***');
|
|
22
18
|
} else {
|
|
23
19
|
return axios.get(
|
|
24
20
|
`/variables/${id}/value`
|
|
@@ -58,7 +54,11 @@ module.exports = (clientID, getSocket) => {
|
|
|
58
54
|
});
|
|
59
55
|
|
|
60
56
|
return unregisterEventHandler;
|
|
61
|
-
}
|
|
57
|
+
},
|
|
58
|
+
onServer: () => ({
|
|
59
|
+
type: 'PolyVariable',
|
|
60
|
+
id
|
|
61
|
+
}),
|
|
62
62
|
});
|
|
63
63
|
});
|
|
64
64
|
return variableHandlers;
|
|
@@ -23,6 +23,15 @@ declare module vari {
|
|
|
23
23
|
* Subscribe to changes to the variable. If the variable is secret, the callback won't be called.
|
|
24
24
|
*/
|
|
25
25
|
onUpdate: (callback: (value: {{type}}) => void) => UnregisterOnUpdateHandler;
|
|
26
|
+
/**
|
|
27
|
+
* Gets variable data.
|
|
28
|
+
* This is intended to be used in Poly functions, so the variable values are resolved on the server
|
|
29
|
+
* without fetching them from the client.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* await poly.products.addItem(vari.products.shopId.onServer(), 'Toy car', 1)
|
|
33
|
+
*/
|
|
34
|
+
onServer: () => {{{type}}};
|
|
26
35
|
}
|
|
27
36
|
{{/each}}
|
|
28
37
|
}
|