@pgpm/measurements 0.4.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.
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Dan Lynch <pyramation@gmail.com>
4
+ Copyright (c) 2025 Interweb, Inc.
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/Makefile ADDED
@@ -0,0 +1,6 @@
1
+ EXTENSION = launchql-measurements
2
+ DATA = sql/launchql-measurements--0.4.6.sql
3
+
4
+ PG_CONFIG = pg_config
5
+ PGXS := $(shell $(PG_CONFIG) --pgxs)
6
+ include $(PGXS)
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # @pgpm/measurements
2
+
3
+ Measurement utilities for performance tracking and analytics.
4
+
5
+ Provides functions for recording, tracking, and analyzing performance measurements and metrics in PostgreSQL applications.
@@ -0,0 +1,309 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`measurements schema should find dimensionless quantities 1`] = `
4
+ {
5
+ "dimensionlessQuantities": [
6
+ {
7
+ "description": "a dimensionless quantity",
8
+ "label": "Dimensionless",
9
+ "name": "Dimensionless",
10
+ "unit": null,
11
+ },
12
+ {
13
+ "description": "something generally accepted as a medium of exchange, a measure of value, or a means of payment",
14
+ "label": "Money",
15
+ "name": "Money",
16
+ "unit": null,
17
+ },
18
+ ],
19
+ }
20
+ `;
21
+
22
+ exports[`measurements schema should find quantities by unit 1`] = `
23
+ {
24
+ "meterQuantities": [
25
+ {
26
+ "label": "Acceleration",
27
+ "name": "Acceleration",
28
+ "unit": "m/s²",
29
+ },
30
+ {
31
+ "label": "Amount Of Substance",
32
+ "name": "AmountOfSubstance",
33
+ "unit": "mol",
34
+ },
35
+ {
36
+ "label": "Area",
37
+ "name": "Area",
38
+ "unit": "m²",
39
+ },
40
+ {
41
+ "label": "Kinematic Viscosity",
42
+ "name": "KinematicViscosity",
43
+ "unit": "m²/s",
44
+ },
45
+ {
46
+ "label": "Length",
47
+ "name": "Length",
48
+ "unit": "m",
49
+ },
50
+ {
51
+ "label": "Luminous Flux",
52
+ "name": "LuminousFlux",
53
+ "unit": "lm",
54
+ },
55
+ {
56
+ "label": "Parts per Million",
57
+ "name": "PartsPerMillion",
58
+ "unit": "ppm",
59
+ },
60
+ {
61
+ "label": "Radiation Dose Effective",
62
+ "name": "RadiationDoseEffective",
63
+ "unit": "equivalent) dose of radiation received by a human or some other living organism. The system unit for this quantity is Sv",
64
+ },
65
+ {
66
+ "label": "Torque",
67
+ "name": "Torque",
68
+ "unit": "N·m",
69
+ },
70
+ {
71
+ "label": "Velocity",
72
+ "name": "Velocity",
73
+ "unit": "m/s",
74
+ },
75
+ {
76
+ "label": "Volume",
77
+ "name": "Volume",
78
+ "unit": "m³",
79
+ },
80
+ {
81
+ "label": "Volumetric Density",
82
+ "name": "VolumetricDensity",
83
+ "unit": "kg/m³",
84
+ },
85
+ {
86
+ "label": "Volumetric Flow Rate",
87
+ "name": "VolumetricFlowRate",
88
+ "unit": "m³/s",
89
+ },
90
+ ],
91
+ }
92
+ `;
93
+
94
+ exports[`measurements schema should handle percentage and parts-per quantities 1`] = `
95
+ {
96
+ "ratioQuantities": [
97
+ {
98
+ "label": "Parts per Billion",
99
+ "name": "PartsPerBillion",
100
+ "unit": "ppb",
101
+ "unit_desc": "parts per billion",
102
+ },
103
+ {
104
+ "label": "Parts per Million",
105
+ "name": "PartsPerMillion",
106
+ "unit": "ppm",
107
+ "unit_desc": "parts per million",
108
+ },
109
+ {
110
+ "label": "Percent",
111
+ "name": "Percent",
112
+ "unit": "%",
113
+ "unit_desc": "percentage",
114
+ },
115
+ ],
116
+ }
117
+ `;
118
+
119
+ exports[`measurements schema should have quantities table with correct structure 1`] = `
120
+ {
121
+ "columns": [
122
+ {
123
+ "column_name": "id",
124
+ "data_type": "integer",
125
+ "is_nullable": "NO",
126
+ },
127
+ {
128
+ "column_name": "name",
129
+ "data_type": "text",
130
+ "is_nullable": "YES",
131
+ },
132
+ {
133
+ "column_name": "label",
134
+ "data_type": "text",
135
+ "is_nullable": "YES",
136
+ },
137
+ {
138
+ "column_name": "unit",
139
+ "data_type": "text",
140
+ "is_nullable": "YES",
141
+ },
142
+ {
143
+ "column_name": "unit_desc",
144
+ "data_type": "text",
145
+ "is_nullable": "YES",
146
+ },
147
+ {
148
+ "column_name": "description",
149
+ "data_type": "text",
150
+ "is_nullable": "YES",
151
+ },
152
+ ],
153
+ }
154
+ `;
155
+
156
+ exports[`measurements schema should retrieve basic physical quantities 1`] = `
157
+ {
158
+ "basicQuantities": [
159
+ {
160
+ "description": "a period of existence or persistence",
161
+ "id": "[ID]",
162
+ "label": "Duration",
163
+ "name": "Duration",
164
+ "unit": "s",
165
+ "unit_desc": "second",
166
+ },
167
+ {
168
+ "description": "the amount of electric charge flowing past a specified circuit point per unit time",
169
+ "id": "[ID]",
170
+ "label": "Electric Current",
171
+ "name": "ElectricCurrent",
172
+ "unit": "A",
173
+ "unit_desc": "Ampere",
174
+ },
175
+ {
176
+ "description": "the extent of something along its greatest dimension or the extent of space between two objects or places",
177
+ "id": "[ID]",
178
+ "label": "Length",
179
+ "name": "Length",
180
+ "unit": "m",
181
+ "unit_desc": "meter",
182
+ },
183
+ {
184
+ "description": "the measure of the quantity of matter that a body or an object contains",
185
+ "id": "[ID]",
186
+ "label": "Mass",
187
+ "name": "Mass",
188
+ "unit": "kg",
189
+ "unit_desc": "kilogram",
190
+ },
191
+ {
192
+ "description": "the degree of hotness or coldness of a body or an environment",
193
+ "id": "[ID]",
194
+ "label": "Temperature",
195
+ "name": "Temperature",
196
+ "unit": "K",
197
+ "unit_desc": "Kelvin",
198
+ },
199
+ ],
200
+ }
201
+ `;
202
+
203
+ exports[`measurements schema should retrieve derived quantities 1`] = `
204
+ {
205
+ "derivedQuantities": [
206
+ {
207
+ "description": "the rate of change of velocity with respect to time",
208
+ "id": "[ID]",
209
+ "label": "Acceleration",
210
+ "name": "Acceleration",
211
+ "unit": "m/s²",
212
+ "unit_desc": "meter per square second",
213
+ },
214
+ {
215
+ "description": "the capacity of a physical system to do work",
216
+ "id": "[ID]",
217
+ "label": "Energy",
218
+ "name": "Energy",
219
+ "unit": "J",
220
+ "unit_desc": "Joule",
221
+ },
222
+ {
223
+ "description": "a quantity that tends to produce an acceleration of a body in the direction of its application",
224
+ "id": "[ID]",
225
+ "label": "Force",
226
+ "name": "Force",
227
+ "unit": "N",
228
+ "unit_desc": "Newton",
229
+ },
230
+ {
231
+ "description": "the rate at which work is done",
232
+ "id": "[ID]",
233
+ "label": "Power",
234
+ "name": "Power",
235
+ "unit": "W",
236
+ "unit_desc": "Watt",
237
+ },
238
+ {
239
+ "description": "a distance traveled divided by the time of travel",
240
+ "id": "[ID]",
241
+ "label": "Velocity",
242
+ "name": "Velocity",
243
+ "unit": "m/s",
244
+ "unit_desc": "meter per second",
245
+ },
246
+ ],
247
+ }
248
+ `;
249
+
250
+ exports[`measurements schema should search quantities by description 1`] = `
251
+ {
252
+ "energyRelated": [
253
+ {
254
+ "description": "the amount of energy deposited per unit of mass",
255
+ "label": "Radiation Dose Absorbed",
256
+ "name": "RadiationDoseAbsorbed",
257
+ },
258
+ ],
259
+ }
260
+ `;
261
+
262
+ exports[`measurements schema should verify SI base units are present 1`] = `
263
+ {
264
+ "siBaseUnits": [
265
+ {
266
+ "label": "Electric Current",
267
+ "name": "ElectricCurrent",
268
+ "unit": "A",
269
+ "unit_desc": "Ampere",
270
+ },
271
+ {
272
+ "label": "Temperature",
273
+ "name": "Temperature",
274
+ "unit": "K",
275
+ "unit_desc": "Kelvin",
276
+ },
277
+ {
278
+ "label": "Luminous Intensity",
279
+ "name": "LuminousIntensity",
280
+ "unit": "cd",
281
+ "unit_desc": "candela",
282
+ },
283
+ {
284
+ "label": "Mass",
285
+ "name": "Mass",
286
+ "unit": "kg",
287
+ "unit_desc": "kilogram",
288
+ },
289
+ {
290
+ "label": "Length",
291
+ "name": "Length",
292
+ "unit": "m",
293
+ "unit_desc": "meter",
294
+ },
295
+ {
296
+ "label": "Amount Of Substance",
297
+ "name": "AmountOfSubstance",
298
+ "unit": "mol",
299
+ "unit_desc": "molecules, for example of a substance. The system unit for this quantity is "mol" mole",
300
+ },
301
+ {
302
+ "label": "Duration",
303
+ "name": "Duration",
304
+ "unit": "s",
305
+ "unit_desc": "second",
306
+ },
307
+ ],
308
+ }
309
+ `;
@@ -0,0 +1,125 @@
1
+ import { getConnections, PgTestClient } from 'pgsql-test';
2
+ import { snapshot } from 'graphile-test';
3
+
4
+ let pg: PgTestClient;
5
+ let teardown: () => Promise<void>;
6
+
7
+ beforeAll(async () => {
8
+ ({ pg, teardown } = await getConnections());
9
+ });
10
+
11
+ afterAll(async () => {
12
+ await teardown();
13
+ });
14
+
15
+ beforeEach(async () => {
16
+ await pg.beforeEach();
17
+ });
18
+
19
+ afterEach(async () => {
20
+ await pg.afterEach();
21
+ });
22
+
23
+ describe('measurements schema', () => {
24
+ it('should have measurements schema created', async () => {
25
+ const schemas = await pg.any(
26
+ `SELECT schema_name FROM information_schema.schemata WHERE schema_name = 'measurements'`
27
+ );
28
+ expect(schemas).toHaveLength(1);
29
+ expect(schemas[0].schema_name).toBe('measurements');
30
+ });
31
+
32
+ it('should have quantities table with correct structure', async () => {
33
+ const columns = await pg.any(
34
+ `SELECT column_name, data_type, is_nullable
35
+ FROM information_schema.columns
36
+ WHERE table_schema = 'measurements' AND table_name = 'quantities'
37
+ ORDER BY ordinal_position`
38
+ );
39
+
40
+ expect(snapshot({ columns })).toMatchSnapshot();
41
+ });
42
+
43
+ it('should have all expected quantities inserted', async () => {
44
+ const quantities = await pg.any(
45
+ `SELECT COUNT(*) as total FROM measurements.quantities`
46
+ );
47
+
48
+ // Based on the SQL file, there should be 44 initial quantities + 3 additional ones (Percent, PartsPerMillion, PartsPerBillion)
49
+ // Note: There's a duplicate ID 45 in the SQL, so actual count might be different
50
+ expect(parseInt(quantities[0].total)).toBeGreaterThan(40);
51
+ });
52
+
53
+ it('should retrieve basic physical quantities', async () => {
54
+ const basicQuantities = await pg.any(
55
+ `SELECT id, name, label, unit, unit_desc, description
56
+ FROM measurements.quantities
57
+ WHERE name IN ('Length', 'Mass', 'Duration', 'Temperature', 'ElectricCurrent')
58
+ ORDER BY name`
59
+ );
60
+
61
+ expect(snapshot({ basicQuantities })).toMatchSnapshot();
62
+ });
63
+
64
+ it('should retrieve derived quantities', async () => {
65
+ const derivedQuantities = await pg.any(
66
+ `SELECT id, name, label, unit, unit_desc, description
67
+ FROM measurements.quantities
68
+ WHERE name IN ('Velocity', 'Acceleration', 'Force', 'Energy', 'Power')
69
+ ORDER BY name`
70
+ );
71
+
72
+ expect(snapshot({ derivedQuantities })).toMatchSnapshot();
73
+ });
74
+
75
+ it('should find quantities by unit', async () => {
76
+ const meterQuantities = await pg.any(
77
+ `SELECT name, label, unit FROM measurements.quantities
78
+ WHERE unit LIKE '%m%'
79
+ ORDER BY name`
80
+ );
81
+
82
+ expect(snapshot({ meterQuantities })).toMatchSnapshot();
83
+ });
84
+
85
+ it('should find dimensionless quantities', async () => {
86
+ const dimensionlessQuantities = await pg.any(
87
+ `SELECT name, label, unit, description FROM measurements.quantities
88
+ WHERE unit IS NULL OR name = 'Dimensionless'
89
+ ORDER BY name`
90
+ );
91
+
92
+ expect(snapshot({ dimensionlessQuantities })).toMatchSnapshot();
93
+ });
94
+
95
+ it('should search quantities by description', async () => {
96
+ const energyRelated = await pg.any(
97
+ `SELECT name, label, description FROM measurements.quantities
98
+ WHERE description ILIKE '%energy%'
99
+ ORDER BY name`
100
+ );
101
+
102
+ expect(snapshot({ energyRelated })).toMatchSnapshot();
103
+ });
104
+
105
+ it('should handle percentage and parts-per quantities', async () => {
106
+ const ratioQuantities = await pg.any(
107
+ `SELECT name, label, unit, unit_desc FROM measurements.quantities
108
+ WHERE name IN ('Percent', 'PartsPerMillion', 'PartsPerBillion')
109
+ ORDER BY name`
110
+ );
111
+
112
+ expect(snapshot({ ratioQuantities })).toMatchSnapshot();
113
+ });
114
+
115
+ it('should verify SI base units are present', async () => {
116
+ // The seven SI base units
117
+ const siBaseUnits = await pg.any(
118
+ `SELECT name, label, unit, unit_desc FROM measurements.quantities
119
+ WHERE unit IN ('m', 'kg', 's', 'A', 'K', 'mol', 'cd')
120
+ ORDER BY unit`
121
+ );
122
+
123
+ expect(snapshot({ siBaseUnits })).toMatchSnapshot();
124
+ });
125
+ });
@@ -0,0 +1,8 @@
1
+ -- Deploy schemas/measurements/schema to pg
2
+
3
+
4
+ BEGIN;
5
+
6
+ CREATE SCHEMA measurements;
7
+
8
+ COMMIT;
@@ -0,0 +1,57 @@
1
+ -- Deploy schemas/measurements/tables/quantities/fixtures/1601076414018_fixture to pg
2
+
3
+ -- requires: schemas/measurements/schema
4
+ -- requires: schemas/measurements/tables/quantities/table
5
+
6
+ BEGIN;
7
+
8
+ -- https://en.wikipedia.org/wiki/International_System_of_Units
9
+ -- https://en.wikipedia.org/wiki/SI_derived_unit
10
+
11
+ INSERT INTO measurements.quantities (id, name, label, unit, unit_desc, description) VALUES
12
+ (1, 'Acceleration', 'Acceleration', 'm/s²', 'meter per square second', 'the rate of change of velocity with respect to time'),
13
+ (2, 'AmountOfSubstance', 'Amount Of Substance', 'mol', 'molecules, for example of a substance. The system unit for this quantity is "mol" mole', 'the number of elementary entities (molecules, for example) of a substance'),
14
+ (3, 'Angle', 'Angle', 'rad', 'radian', 'the figure formed by two lines diverging from a common point'),
15
+ (4, 'AngularAcceleration', 'Angular Acceleration', 'rad/s²', 'radian per square second', 'the rate of change of angular velocity with respect to time'),
16
+ (5, 'AngularVelocity', 'Angular Velocity', 'rad/s', 'radian per second', 'the rate of change of angular displacement with respect to time'),
17
+ (6, 'Area', 'Area', 'm²', 'square meter', 'the extent of a planar region or of the surface of a solid measured in square units'),
18
+ (7, 'CatalyticActivity', 'Catalytic Activity', 'kat', 'katal', 'a catalytic activity'),
19
+ (8, 'DataAmount', 'Data Amount', 'bit', NULL, 'a measure of data amount'),
20
+ (9, 'DataRate', 'Data Rate', 'bit/s', 'bit per second', 'the speed of data-transmission'),
21
+ (10, 'Dimensionless', 'Dimensionless', NULL, NULL, 'a dimensionless quantity'),
22
+ (11, 'Duration', 'Duration', 's', 'second', 'a period of existence or persistence'),
23
+ (12, 'DynamicViscosity', 'Dynamic Viscosity', 'Pa·s', 'Pascal-Second', 'the dynamic viscosity'),
24
+ (13, 'ElectricCapacitance', 'Electric Capacitance', 'F', 'Farad', 'an electric capacitance'),
25
+ (14, 'ElectricCharge', 'Electric Charge', 'C', 'Coulomb', 'an electric charge'),
26
+ (15, 'ElectricConductance', 'Electric Conductance', 'S', 'Siemens', 'an electric conductance'),
27
+ (16, 'ElectricCurrent', 'Electric Current', 'A', 'Ampere', 'the amount of electric charge flowing past a specified circuit point per unit time'),
28
+ (17, 'ElectricInductance', 'Electric Inductance', 'H', 'Henry', 'an electric inductance'),
29
+ (18, 'ElectricPotential', 'Electric Potential', 'V', 'Volt', 'an electric potential or electromotive force'),
30
+ (19, 'ElectricResistance', 'Electric Resistance', 'Ω', 'Ohm', 'an electric resistance'),
31
+ (20, 'Energy', 'Energy', 'J', 'Joule', 'the capacity of a physical system to do work'),
32
+ (21, 'Force', 'Force', 'N', 'Newton', 'a quantity that tends to produce an acceleration of a body in the direction of its application'),
33
+ (22, 'Frequency', 'Frequency', 'Hz', 'Hertz', 'the number of times a specified phenomenon occurs within a specified interval'),
34
+ (23, 'Illuminance', 'Illuminance', 'lx', 'lux', 'an illuminance'),
35
+ (24, 'KinematicViscosity', 'Kinematic Viscosity', 'm²/s', NULL, 'the diffusion of momentum'),
36
+ (25, 'Length', 'Length', 'm', 'meter', 'the extent of something along its greatest dimension or the extent of space between two objects or places'),
37
+ (26, 'LuminousFlux', 'Luminous Flux', 'lm', 'lumen', 'a luminous flux'),
38
+ (27, 'LuminousIntensity', 'Luminous Intensity', 'cd', 'candela', 'the luminous flux density per solid angle as measured in a given direction relative to the emitting source'),
39
+ (28, 'MagneticFlux', 'Magnetic Flux', 'Wb', 'Weber', 'a magnetic flux'),
40
+ (29, 'MagneticFluxDensity', 'Magnetic Flux Density', 'T', 'Tesla', 'a magnetic flux density'),
41
+ (30, 'Mass', 'Mass', 'kg', 'kilogram', 'the measure of the quantity of matter that a body or an object contains'),
42
+ (31, 'MassFlowRate', 'Mass Flow Rate', 'kg/s', 'kilogram per second', 'the movement of mass per time'),
43
+ (32, 'Money', 'Money', NULL, NULL, 'something generally accepted as a medium of exchange, a measure of value, or a means of payment'),
44
+ (33, 'Power', 'Power', 'W', 'Watt', 'the rate at which work is done'),
45
+ (34, 'Pressure', 'Pressure', 'Pa', 'Pascal', 'a force applied uniformly over a surface'),
46
+ (35, 'RadiationDoseAbsorbed', 'Radiation Dose Absorbed', 'Gy', 'Gray', 'the amount of energy deposited per unit of mass'),
47
+ (36, 'RadiationDoseEffective', 'Radiation Dose Effective', 'equivalent) dose of radiation received by a human or some other living organism. The system unit for this quantity is Sv', 'or "equivalent" dose of radiation received by a human or some other living organism. The system unit for this quantity is "Sv" Sievert', 'the effective (or "equivalent") dose of radiation received by a human or some other living organism'),
48
+ (37, 'RadioactiveActivity', 'Radioactive Activity', 'Bq', 'Becquerel', 'a radioactive activity'),
49
+ (38, 'SolidAngle', 'Solid Angle', 'sr', 'steradian', 'the angle formed by three or more planes intersecting at a common point'),
50
+ (39, 'Temperature', 'Temperature', 'K', 'Kelvin', 'the degree of hotness or coldness of a body or an environment'),
51
+ (40, 'Torque', 'Torque', 'N·m', 'Newton-Meter', 'the moment of a force'),
52
+ (41, 'Velocity', 'Velocity', 'm/s', 'meter per second', 'a distance traveled divided by the time of travel'),
53
+ (42, 'Volume', 'Volume', 'm³', 'cubic meter', 'the amount of space occupied by a three-dimensional object or region of space, expressed in cubic units'),
54
+ (43, 'VolumetricDensity', 'Volumetric Density', 'kg/m³', 'kilogram per cubic meter', 'a mass per unit volume of a substance under specified conditions of pressure and temperature'),
55
+ (44, 'VolumetricFlowRate', 'Volumetric Flow Rate', 'm³/s', 'cubic meter per second', 'the volume of fluid passing a point in a system per unit of time');
56
+
57
+ COMMIT;
@@ -0,0 +1,21 @@
1
+ -- Deploy schemas/measurements/tables/quantities/fixtures/1601081365273_fixture to pg
2
+
3
+ -- requires: schemas/measurements/schema
4
+ -- requires: schemas/measurements/tables/quantities/table
5
+
6
+ BEGIN;
7
+
8
+
9
+ INSERT INTO measurements.quantities (id, name, label, unit, unit_desc, description) VALUES
10
+ -- these are dimensionless https://en.wikipedia.org/wiki/Parts-per_notation
11
+ -- parts per 100
12
+
13
+ -- measures of concetration
14
+ (45, 'Percent', 'Percent', '%', 'percentage', 'a number or ratio expressed as a fraction of 100'),
15
+ -- parts per 1M
16
+ (46, 'PartsPerMillion', 'Parts per Million', 'ppm', 'parts per million', 'pseudo-units to describe small values of miscellaneous dimensionless quantities that are pure numbers representing a quantity-per-quantity measure in parts per million'),
17
+ -- parts per 1B
18
+ (47, 'PartsPerBillion', 'Parts per Billion', 'ppb', 'parts per billion', 'pseudo-units to describe small values of miscellaneous dimensionless quantities that are pure numbers representing a quantity-per-quantity measure in parts per billion')
19
+ ;
20
+
21
+ COMMIT;
@@ -0,0 +1,16 @@
1
+ -- Deploy schemas/measurements/tables/quantities/table to pg
2
+
3
+ -- requires: schemas/measurements/schema
4
+
5
+ BEGIN;
6
+
7
+ CREATE TABLE measurements.quantities (
8
+ id serial PRIMARY KEY,
9
+ name text,
10
+ label text,
11
+ unit text,
12
+ unit_desc text,
13
+ description text
14
+ );
15
+
16
+ COMMIT;
package/jest.config.js ADDED
@@ -0,0 +1,15 @@
1
+ /** @type {import('ts-jest').JestConfigWithTsJest} */
2
+ module.exports = {
3
+ preset: 'ts-jest',
4
+ testEnvironment: 'node',
5
+
6
+ // Match both __tests__ and colocated test files
7
+ testMatch: ['**/?(*.)+(test|spec).{ts,tsx,js,jsx}'],
8
+
9
+ // Ignore build artifacts and type declarations
10
+ testPathIgnorePatterns: ['/dist/', '\\.d\\.ts$'],
11
+ modulePathIgnorePatterns: ['<rootDir>/dist/'],
12
+ watchPathIgnorePatterns: ['/dist/'],
13
+
14
+ moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
15
+ };
@@ -0,0 +1,8 @@
1
+ # launchql-measurements extension
2
+ comment = 'launchql-measurements extension'
3
+ default_version = '0.4.6'
4
+ module_pathname = '$libdir/launchql-measurements'
5
+ requires = 'plpgsql,launchql-verify'
6
+ relocatable = false
7
+ superuser = false
8
+
package/launchql.plan ADDED
@@ -0,0 +1,8 @@
1
+ %syntax-version=1.0.0
2
+ %project=launchql-measurements
3
+ %uri=launchql-measurements
4
+
5
+ schemas/measurements/schema 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/measurements/schema
6
+ schemas/measurements/tables/quantities/table [schemas/measurements/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/measurements/tables/quantities/table
7
+ schemas/measurements/tables/quantities/fixtures/1601076414018_fixture [schemas/measurements/schema schemas/measurements/tables/quantities/table] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/measurements/tables/quantities/fixtures/1601076414018_fixture
8
+ schemas/measurements/tables/quantities/fixtures/1601081365273_fixture [schemas/measurements/schema schemas/measurements/tables/quantities/table] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/measurements/tables/quantities/fixtures/1601081365273_fixture
@@ -0,0 +1,8 @@
1
+ # measurements extension
2
+ comment = 'measurements extension'
3
+ default_version = '0.0.1'
4
+ module_pathname = '$libdir/measurements'
5
+ requires = 'plpgsql,uuid-ossp,launchql-verify'
6
+ relocatable = false
7
+ superuser = false
8
+
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@pgpm/measurements",
3
+ "version": "0.4.0",
4
+ "description": "Measurement utilities for performance tracking and analytics",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "scripts": {
9
+ "bundle": "lql package",
10
+ "test": "jest",
11
+ "test:watch": "jest --watch"
12
+ },
13
+ "dependencies": {
14
+ "@pgpm/verify": "0.4.0"
15
+ },
16
+ "devDependencies": {
17
+ "@launchql/cli": "^4.9.0"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/launchql/extensions"
22
+ },
23
+ "homepage": "https://github.com/launchql/extensions",
24
+ "bugs": {
25
+ "url": "https://github.com/launchql/extensions/issues"
26
+ },
27
+ "gitHead": "cc9f52a335caa6e21ee7751b04b77c84ce6cb809"
28
+ }
@@ -0,0 +1,7 @@
1
+ -- Revert schemas/measurements/schema from pg
2
+
3
+ BEGIN;
4
+
5
+ DROP SCHEMA measurements;
6
+
7
+ COMMIT;
@@ -0,0 +1,5 @@
1
+ -- Revert schemas/measurements/tables/quantities/fixtures/1601076414018_fixture from pg
2
+
3
+ BEGIN;
4
+
5
+ COMMIT;
@@ -0,0 +1,5 @@
1
+ -- Revert schemas/measurements/tables/quantities/fixtures/1601081365273_fixture from pg
2
+
3
+ BEGIN;
4
+
5
+ COMMIT;
@@ -0,0 +1,7 @@
1
+ -- Revert schemas/measurements/tables/quantities/table from pg
2
+
3
+ BEGIN;
4
+
5
+ DROP TABLE measurements.quantities;
6
+
7
+ COMMIT;
package/sqitch.plan ADDED
@@ -0,0 +1,8 @@
1
+ %syntax-version=1.0.0
2
+ %project=launchql-measurements
3
+ %uri=launchql-measurements
4
+
5
+ schemas/measurements/schema 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/measurements/schema
6
+ schemas/measurements/tables/quantities/table [schemas/measurements/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/measurements/tables/quantities/table
7
+ schemas/measurements/tables/quantities/fixtures/1601076414018_fixture [schemas/measurements/schema schemas/measurements/tables/quantities/table] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/measurements/tables/quantities/fixtures/1601076414018_fixture
8
+ schemas/measurements/tables/quantities/fixtures/1601081365273_fixture [schemas/measurements/schema schemas/measurements/tables/quantities/table] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/measurements/tables/quantities/fixtures/1601081365273_fixture
@@ -0,0 +1,76 @@
1
+ \echo Use "CREATE EXTENSION launchql-measurements" to load this file. \quit
2
+ CREATE SCHEMA measurements;
3
+
4
+ CREATE TABLE measurements.quantities (
5
+ id serial PRIMARY KEY,
6
+ name text,
7
+ label text,
8
+ unit text,
9
+ unit_desc text,
10
+ description text
11
+ );
12
+
13
+ INSERT INTO measurements.quantities (
14
+ id,
15
+ name,
16
+ label,
17
+ unit,
18
+ unit_desc,
19
+ description
20
+ ) VALUES
21
+ (1, 'Acceleration', 'Acceleration', 'm/s²', 'meter per square second', 'the rate of change of velocity with respect to time'),
22
+ (2, 'AmountOfSubstance', 'Amount Of Substance', 'mol', 'molecules, for example of a substance. The system unit for this quantity is "mol" mole', 'the number of elementary entities (molecules, for example) of a substance'),
23
+ (3, 'Angle', 'Angle', 'rad', 'radian', 'the figure formed by two lines diverging from a common point'),
24
+ (4, 'AngularAcceleration', 'Angular Acceleration', 'rad/s²', 'radian per square second', 'the rate of change of angular velocity with respect to time'),
25
+ (5, 'AngularVelocity', 'Angular Velocity', 'rad/s', 'radian per second', 'the rate of change of angular displacement with respect to time'),
26
+ (6, 'Area', 'Area', 'm²', 'square meter', 'the extent of a planar region or of the surface of a solid measured in square units'),
27
+ (7, 'CatalyticActivity', 'Catalytic Activity', 'kat', 'katal', 'a catalytic activity'),
28
+ (8, 'DataAmount', 'Data Amount', 'bit', NULL, 'a measure of data amount'),
29
+ (9, 'DataRate', 'Data Rate', 'bit/s', 'bit per second', 'the speed of data-transmission'),
30
+ (10, 'Dimensionless', 'Dimensionless', NULL, NULL, 'a dimensionless quantity'),
31
+ (11, 'Duration', 'Duration', 's', 'second', 'a period of existence or persistence'),
32
+ (12, 'DynamicViscosity', 'Dynamic Viscosity', 'Pa·s', 'Pascal-Second', 'the dynamic viscosity'),
33
+ (13, 'ElectricCapacitance', 'Electric Capacitance', 'F', 'Farad', 'an electric capacitance'),
34
+ (14, 'ElectricCharge', 'Electric Charge', 'C', 'Coulomb', 'an electric charge'),
35
+ (15, 'ElectricConductance', 'Electric Conductance', 'S', 'Siemens', 'an electric conductance'),
36
+ (16, 'ElectricCurrent', 'Electric Current', 'A', 'Ampere', 'the amount of electric charge flowing past a specified circuit point per unit time'),
37
+ (17, 'ElectricInductance', 'Electric Inductance', 'H', 'Henry', 'an electric inductance'),
38
+ (18, 'ElectricPotential', 'Electric Potential', 'V', 'Volt', 'an electric potential or electromotive force'),
39
+ (19, 'ElectricResistance', 'Electric Resistance', 'Ω', 'Ohm', 'an electric resistance'),
40
+ (20, 'Energy', 'Energy', 'J', 'Joule', 'the capacity of a physical system to do work'),
41
+ (21, 'Force', 'Force', 'N', 'Newton', 'a quantity that tends to produce an acceleration of a body in the direction of its application'),
42
+ (22, 'Frequency', 'Frequency', 'Hz', 'Hertz', 'the number of times a specified phenomenon occurs within a specified interval'),
43
+ (23, 'Illuminance', 'Illuminance', 'lx', 'lux', 'an illuminance'),
44
+ (24, 'KinematicViscosity', 'Kinematic Viscosity', 'm²/s', NULL, 'the diffusion of momentum'),
45
+ (25, 'Length', 'Length', 'm', 'meter', 'the extent of something along its greatest dimension or the extent of space between two objects or places'),
46
+ (26, 'LuminousFlux', 'Luminous Flux', 'lm', 'lumen', 'a luminous flux'),
47
+ (27, 'LuminousIntensity', 'Luminous Intensity', 'cd', 'candela', 'the luminous flux density per solid angle as measured in a given direction relative to the emitting source'),
48
+ (28, 'MagneticFlux', 'Magnetic Flux', 'Wb', 'Weber', 'a magnetic flux'),
49
+ (29, 'MagneticFluxDensity', 'Magnetic Flux Density', 'T', 'Tesla', 'a magnetic flux density'),
50
+ (30, 'Mass', 'Mass', 'kg', 'kilogram', 'the measure of the quantity of matter that a body or an object contains'),
51
+ (31, 'MassFlowRate', 'Mass Flow Rate', 'kg/s', 'kilogram per second', 'the movement of mass per time'),
52
+ (32, 'Money', 'Money', NULL, NULL, 'something generally accepted as a medium of exchange, a measure of value, or a means of payment'),
53
+ (33, 'Power', 'Power', 'W', 'Watt', 'the rate at which work is done'),
54
+ (34, 'Pressure', 'Pressure', 'Pa', 'Pascal', 'a force applied uniformly over a surface'),
55
+ (35, 'RadiationDoseAbsorbed', 'Radiation Dose Absorbed', 'Gy', 'Gray', 'the amount of energy deposited per unit of mass'),
56
+ (36, 'RadiationDoseEffective', 'Radiation Dose Effective', 'equivalent) dose of radiation received by a human or some other living organism. The system unit for this quantity is Sv', 'or "equivalent" dose of radiation received by a human or some other living organism. The system unit for this quantity is "Sv" Sievert', 'the effective (or "equivalent") dose of radiation received by a human or some other living organism'),
57
+ (37, 'RadioactiveActivity', 'Radioactive Activity', 'Bq', 'Becquerel', 'a radioactive activity'),
58
+ (38, 'SolidAngle', 'Solid Angle', 'sr', 'steradian', 'the angle formed by three or more planes intersecting at a common point'),
59
+ (39, 'Temperature', 'Temperature', 'K', 'Kelvin', 'the degree of hotness or coldness of a body or an environment'),
60
+ (40, 'Torque', 'Torque', 'N·m', 'Newton-Meter', 'the moment of a force'),
61
+ (41, 'Velocity', 'Velocity', 'm/s', 'meter per second', 'a distance traveled divided by the time of travel'),
62
+ (42, 'Volume', 'Volume', 'm³', 'cubic meter', 'the amount of space occupied by a three-dimensional object or region of space, expressed in cubic units'),
63
+ (43, 'VolumetricDensity', 'Volumetric Density', 'kg/m³', 'kilogram per cubic meter', 'a mass per unit volume of a substance under specified conditions of pressure and temperature'),
64
+ (44, 'VolumetricFlowRate', 'Volumetric Flow Rate', 'm³/s', 'cubic meter per second', 'the volume of fluid passing a point in a system per unit of time');
65
+
66
+ INSERT INTO measurements.quantities (
67
+ id,
68
+ name,
69
+ label,
70
+ unit,
71
+ unit_desc,
72
+ description
73
+ ) VALUES
74
+ (45, 'Percent', 'Percent', '%', 'percentage', 'a number or ratio expressed as a fraction of 100'),
75
+ (46, 'PartsPerMillion', 'Parts per Million', 'ppm', 'parts per million', 'pseudo-units to describe small values of miscellaneous dimensionless quantities that are pure numbers representing a quantity-per-quantity measure in parts per million'),
76
+ (47, 'PartsPerBillion', 'Parts per Billion', 'ppb', 'parts per billion', 'pseudo-units to describe small values of miscellaneous dimensionless quantities that are pure numbers representing a quantity-per-quantity measure in parts per billion');
@@ -0,0 +1,7 @@
1
+ -- Verify schemas/measurements/schema on pg
2
+
3
+ BEGIN;
4
+
5
+ SELECT verify_schema ('measurements');
6
+
7
+ ROLLBACK;
@@ -0,0 +1,5 @@
1
+ -- Verify schemas/measurements/tables/quantities/fixtures/1601076414018_fixture on pg
2
+
3
+ BEGIN;
4
+
5
+ ROLLBACK;
@@ -0,0 +1,5 @@
1
+ -- Verify schemas/measurements/tables/quantities/fixtures/1601081365273_fixture on pg
2
+
3
+ BEGIN;
4
+
5
+ ROLLBACK;
@@ -0,0 +1,7 @@
1
+ -- Verify schemas/measurements/tables/quantities/table on pg
2
+
3
+ BEGIN;
4
+
5
+ SELECT verify_table ('measurements.quantities');
6
+
7
+ ROLLBACK;