alchemy 0.0.7 → 0.1.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.
Files changed (105) hide show
  1. package/package.json +23 -22
  2. package/src/alchemize.ts +151 -0
  3. package/src/apply.ts +117 -0
  4. package/src/components/agent/agent.ts +45 -0
  5. package/src/components/agent/anthropic.ts +27 -0
  6. package/src/components/agent/index.ts +4 -0
  7. package/src/components/agent/model.ts +22 -0
  8. package/src/components/agent/openai.ts +44 -0
  9. package/src/components/agent/package.ts +126 -0
  10. package/src/components/agent/requirements.ts +111 -0
  11. package/src/components/agent/scrape.ts +47 -0
  12. package/src/components/agent/tsconfig.ts +150 -0
  13. package/src/components/agent/typescript.ts +177 -0
  14. package/src/components/aws/bucket.ts +168 -0
  15. package/src/components/aws/function.ts +302 -0
  16. package/src/components/aws/index.ts +6 -0
  17. package/src/components/aws/policy.ts +245 -0
  18. package/src/components/aws/queue.ts +222 -0
  19. package/src/components/aws/role.ts +245 -0
  20. package/src/components/aws/table.ts +172 -0
  21. package/src/components/esbuild.ts +128 -0
  22. package/src/components/fs.ts +45 -0
  23. package/src/destroy.ts +63 -0
  24. package/src/error.ts +16 -0
  25. package/src/global.ts +72 -0
  26. package/src/index.ts +6 -0
  27. package/src/input.ts +16 -0
  28. package/src/main.ts +34 -0
  29. package/src/output.ts +49 -0
  30. package/src/resource.ts +313 -0
  31. package/src/state.ts +100 -0
  32. package/test/aws/function.test.ts +144 -0
  33. package/test/aws/queue.test.ts +85 -0
  34. package/test/aws/role.test.ts +153 -0
  35. package/test/aws/table.test.ts +73 -0
  36. package/test/esbuild.test.ts +41 -0
  37. package/test/handler.ts +9 -0
  38. package/tsconfig.json +7 -0
  39. package/Column.js +0 -1
  40. package/Create.js +0 -1
  41. package/Delete.js +0 -1
  42. package/Drop.js +0 -1
  43. package/Insert.js +0 -1
  44. package/Makefile +0 -8
  45. package/README.md +0 -0
  46. package/Select.js +0 -1
  47. package/Table.js +0 -1
  48. package/Transaction.js +0 -1
  49. package/Types.js +0 -1
  50. package/Update.js +0 -1
  51. package/alchemy.js +0 -57
  52. package/alchemy.sublime-project +0 -9
  53. package/alchemy.sublime-workspace +0 -2304
  54. package/config/app.js +0 -8
  55. package/config/db.js +0 -20
  56. package/copy.js +0 -1
  57. package/defaultEngine.js +0 -8
  58. package/engine.js +0 -282
  59. package/getInstantiatorFunction.js +0 -28
  60. package/index.js +0 -52
  61. package/jstest.js +0 -3
  62. package/loggerFactory.js +0 -27
  63. package/logs/alchemy.log +0 -46
  64. package/logs/sql.log +0 -41
  65. package/sql/Column.js +0 -158
  66. package/sql/Columnable.js +0 -21
  67. package/sql/Create.js +0 -15
  68. package/sql/Delete.js +0 -34
  69. package/sql/Drop.js +0 -36
  70. package/sql/Insert.js +0 -96
  71. package/sql/SchemaElement.js +0 -11
  72. package/sql/Select.js +0 -192
  73. package/sql/SqlBase.js +0 -134
  74. package/sql/SqlStatement.js +0 -80
  75. package/sql/Table.js +0 -96
  76. package/sql/Transaction.js +0 -45
  77. package/sql/Update.js +0 -105
  78. package/sql/defineElement.js +0 -26
  79. package/sql/defineStatement.js +0 -26
  80. package/sql/types/BaseType.js +0 -43
  81. package/sql/types/BigSerialType.js +0 -5
  82. package/sql/types/IntegerType.js +0 -5
  83. package/sql/types/JsonType.js +0 -5
  84. package/sql/types/SerialType.js +0 -5
  85. package/sql/types/StringType.js +0 -31
  86. package/sql/types/TimestampType.js +0 -5
  87. package/sql/types/UUIDType.js +0 -5
  88. package/sql/types/defineType.js +0 -25
  89. package/sql/types/getType.js +0 -12
  90. package/sql/types/index.js +0 -11
  91. package/sql/where.js +0 -31
  92. package/sql/whereToString.js +0 -29
  93. package/test/ColumnTests.js +0 -80
  94. package/test/CreateTable.js +0 -54
  95. package/test/DeleteTests.js +0 -28
  96. package/test/DropTests.js +0 -23
  97. package/test/GetTypeTests.js +0 -56
  98. package/test/InsertTests.js +0 -86
  99. package/test/SelectExistsTests.js +0 -26
  100. package/test/SelectTests.js +0 -130
  101. package/test/TableTests.js +0 -46
  102. package/test.js +0 -8
  103. package/test.ls +0 -4
  104. package/validate.js +0 -26
  105. package/x.js +0 -5
@@ -1,54 +0,0 @@
1
- var Types = require('../Types')
2
- var Table = require('../Table')
3
- var Column = require('../Column')
4
-
5
- describe('Create table', function(){
6
-
7
-
8
- it('should build create statement correctly', function(){
9
-
10
- var table = Table('users', null,
11
- Column('id', Types.Integer),
12
- Column('color', Types.String(10))
13
- )
14
-
15
- table
16
- .toString()
17
- .should.equal('CREATE TABLE IF NOT EXISTS users (id integer, color varchar(10));')
18
-
19
- })
20
-
21
- it('should create table with primary key', function(){
22
-
23
- var table = Table('users', null,
24
- Column('id', Types.Integer, { primaryKey: true })
25
- )
26
-
27
- table
28
- .toString()
29
- .should.equal('CREATE TABLE IF NOT EXISTS users (id integer PRIMARY KEY);')
30
- })
31
-
32
- it('should work with unique column', function(){
33
- var table = Table('users', null,
34
- Column('id', Types.Integer, { primaryKey: true }),
35
- Column('email', Types.String(100), { unique: true })
36
- )
37
-
38
- table
39
- .toString()
40
- .should.equal('CREATE TABLE IF NOT EXISTS users (id integer PRIMARY KEY, email varchar(100) UNIQUE);')
41
- })
42
-
43
- it('should work with unique not null column', function(){
44
- var table = Table('users', null,
45
- Column('id', Types.Integer, { primaryKey: true }),
46
- Column('email', Types.String(100), { unique: true, notNull: true })
47
- )
48
-
49
- table
50
- .toString()
51
- .should.equal('CREATE TABLE IF NOT EXISTS users (id integer PRIMARY KEY, email varchar(100) UNIQUE NOT NULL);')
52
- })
53
-
54
- })
@@ -1,28 +0,0 @@
1
- var Select = require('../Select')
2
- var Types = require('../Types')
3
- var Table = require('../Table')
4
- var Column = require('../Column')
5
- var Delete = require('../Delete')
6
-
7
- describe('Delete', function(){
8
-
9
- var table = Table('users', null,
10
- Column('name', Types.String),
11
- Column('id', Types.String),
12
- Column('color', Types.String)
13
- )
14
-
15
- it('should delete where name and id', function(){
16
-
17
- var name = table.c.name
18
- var idCol = table.c.id
19
-
20
- Delete(table)
21
- .where('name').is('x')
22
- .and('id').is(5)
23
- .end()
24
- .toString()
25
- .should.equal('DELETE FROM users WHERE name = \'x\' AND id = 5')
26
-
27
- })
28
- })
package/test/DropTests.js DELETED
@@ -1,23 +0,0 @@
1
- var Select = require('../Select')
2
- var Types = require('../Types')
3
- var Table = require('../Table')
4
- var Column = require('../Column')
5
- var Drop = require('../Drop')
6
-
7
- describe('Drop', function(){
8
-
9
- var table = Table('users', null,
10
- Column('name', Types.String),
11
- Column('id', Types.String),
12
- Column('color', Types.String)
13
- )
14
-
15
- it('should drop table', function(){
16
-
17
-
18
- Drop().table(table)
19
- .toString()
20
- .should.equal('DROP TABLE users')
21
-
22
- })
23
- })
@@ -1,56 +0,0 @@
1
- var Types = require('../Types')
2
-
3
- describe('GetType', function(){
4
-
5
- var getType = require('../sql/types/getType')
6
-
7
- it('should find string type', function(){
8
-
9
- getType({
10
- type: 'string'
11
- })
12
- .should
13
- .equal(Types.String)
14
-
15
- })
16
-
17
- it('should find json type', function(){
18
-
19
- getType({
20
- type: 'json'
21
- })
22
- .should
23
- .equal(Types.Json)
24
-
25
- })
26
-
27
- it('should find integer type', function(){
28
-
29
- getType({
30
- type: 'integer'
31
- })
32
- .should
33
- .equal(Types.Integer)
34
-
35
- })
36
-
37
- it('should find serial type', function(){
38
-
39
- getType({
40
- type: 'serial'
41
- })
42
- .should
43
- .equal(Types.Serial)
44
-
45
- })
46
-
47
- it('should find bigserial type', function(){
48
-
49
- getType({
50
- type: 'bigserial'
51
- })
52
- .should
53
- .equal(Types.BigSerial)
54
- })
55
-
56
- })
@@ -1,86 +0,0 @@
1
- var Insert = require('../Insert')
2
- var Types = require('../Types')
3
- var Table = require('../Table')
4
- var Column = require('../Column')
5
-
6
- describe('Insert', function(){
7
-
8
- var table = Table('users', null,
9
- Column('name', Types.String),
10
- Column('id', Types.String),
11
- Column('color', Types.String)
12
- )
13
-
14
- it('should have a name', function(){
15
- var insert = table.insert()
16
-
17
- insert.name
18
- .should.equal('insert')
19
- })
20
-
21
- it('should have proper state', function(){
22
- var insert = table.insert()
23
- .set('parameterized', false)
24
-
25
- var state = insert.toState()
26
-
27
- state.name
28
- .should.equal('insert')
29
- state.parameterized
30
- .should.equal(false)
31
-
32
- state.columns[0].name
33
- .should.equal('name')
34
- state.columns[1].name
35
- .should.equal('id')
36
- state.columns.length
37
- .should.equal(3)
38
- })
39
-
40
- it('should insert name and id correctly', function(){
41
-
42
- var insert = table.insert()
43
- .set('parameterized', false)
44
- .values({
45
- name: 'x',
46
- id: 1
47
- })
48
-
49
- insert
50
- .toString()
51
- .should.equal(
52
- "INSERT INTO users (name, id) VALUES ('x', 1);"
53
- )
54
-
55
- })
56
-
57
- it('should insert null values correctly', function(){
58
- table.insert()
59
- .values({
60
- name: null,
61
- id: 1
62
- })
63
- .toString()
64
- .should.equal(
65
- "INSERT INTO users (name, id) VALUES (null, 1);"
66
- )
67
- })
68
-
69
- it('should insert multiple values correctly', function(){
70
- var insert = table.insert().values([{
71
- name: 'x',
72
- id: 1,
73
- color: 'red'
74
- }, {
75
- name: 'b',
76
- id: 2
77
- }])
78
-
79
- insert
80
- .set('parameterized', false)
81
- .toString()
82
- .should.equal(
83
- "INSERT INTO users (name, id, color) VALUES ('x', 1, 'red'), ('b', 2, null);"
84
- )
85
- })
86
- })
@@ -1,26 +0,0 @@
1
- var Select = require('../Select')
2
- var Types = require('../Types')
3
- var Table = require('../Table')
4
- var Column = require('../Column')
5
-
6
- describe('Select exists', function(){
7
-
8
- it('should return correct query', function(){
9
-
10
- Select(Column('table_name').as('name'))
11
- .from('information_schema.tables')
12
- .where('table_schema')
13
- .is('public')
14
- .and('table_name')
15
- .is('users')
16
- .end()
17
- .exists()
18
- .toString()
19
- .should
20
- .equal('SELECT EXISTS(' +
21
- 'SELECT table_name AS name FROM information_schema.tables ' +
22
- 'WHERE table_schema = \'public\' AND table_name = \'users\'' +
23
- ')')
24
- })
25
-
26
- })
@@ -1,130 +0,0 @@
1
- var Select = require('../Select')
2
- var Types = require('../Types')
3
- var Table = require('../Table')
4
- var Column = require('../Column')
5
-
6
- describe('Select', function(){
7
-
8
- var table = Table('users', null,
9
- Column('name', Types.String),
10
- Column('id', Types.String),
11
- Column('color', Types.String)
12
- )
13
-
14
- it('should select name and id correctly', function(){
15
-
16
- var name = table.c.name
17
- var idCol = table.c.id
18
-
19
- Select(name, idCol)
20
- .set('parameterized', false)
21
- .toString()
22
- .should.equal('SELECT name, id FROM users')
23
-
24
- })
25
-
26
- it('should select all', function(){
27
- table.select()
28
- .toString()
29
- .should.equal('SELECT * FROM users')
30
- })
31
-
32
- it('should select name where correctly', function(){
33
-
34
- var name = table.c.name
35
- var idCol = table.c.id
36
-
37
- Select(name)
38
- .set('parameterized', false)
39
- .where(name)
40
- .equals('test')
41
- .and(idCol)
42
- .lt(1)
43
- .toString()
44
- .should.equal("SELECT name FROM users WHERE name = 'test' AND id < 1")
45
-
46
- })
47
-
48
- it('should paginate correctly', function(){
49
-
50
- var name = table.c.name
51
- var idCol = table.c.id
52
-
53
- Select(name)
54
- .set('parameterized', false)
55
- .limit(5)
56
- .page(3)
57
- .toString()
58
- .should.equal("SELECT name FROM users LIMIT 5 OFFSET 10")
59
- })
60
-
61
- it('should select count column', function(){
62
- var name = table.c.name
63
- var idCol = table.c.id
64
-
65
- Select(name.count().as('x'))
66
- .toString()
67
- .should.equal("SELECT COUNT(name) AS x FROM users")
68
- })
69
-
70
- it('should select function call', function(){
71
- Select('uuid_generate_v4()')
72
- .toString()
73
- .should.equal("SELECT uuid_generate_v4()")
74
- })
75
-
76
- it('should select function call', function(){
77
- Select(Column('uuid_generate_v4()').as('uuid'))
78
- .toString()
79
- .should.equal("SELECT uuid_generate_v4() AS uuid")
80
- })
81
-
82
- })
83
-
84
- describe('Select clone', function(){
85
-
86
- var table = Table('users', null,
87
- Column('name', Types.String),
88
- Column('id', Types.String),
89
- Column('color', Types.String)
90
- )
91
-
92
- it('should result in same toString', function(){
93
-
94
- var name = table.c.name
95
- var idCol = table.c.id
96
-
97
- var toString = 'SELECT name, id FROM users'
98
-
99
- var select = Select(name, idCol)
100
- .set('parameterized', false)
101
-
102
- select
103
- .toString()
104
- .should
105
- .equal(toString)
106
-
107
- var clone = select
108
- .clone()
109
-
110
- clone.toString()
111
- .should.equal(toString)
112
- })
113
-
114
- it('should clone where', function(){
115
-
116
- var name = table.c.name
117
- var idCol = table.c.id
118
-
119
- var toString = 'SELECT name, id FROM users WHERE id = 2'
120
-
121
- var select = Select(name, idCol)
122
- .set('parameterized', false)
123
- .where(idCol).is(2).end()
124
-
125
- var clone = select.clone()
126
-
127
- clone.toString()
128
- .should.equal(toString)
129
- })
130
- })
@@ -1,46 +0,0 @@
1
- var Types = require('../Types')
2
- var Table = require('../Table')
3
- var Column = require('../Column')
4
-
5
- describe('Table', function(){
6
-
7
-
8
- it('should correctly return from toState()', function(){
9
-
10
- var table = Table('users', null,
11
- Column('id', Types.Integer),
12
- Column('color', Types.String(10))
13
- )
14
-
15
- var state = table.toState()
16
-
17
- state.name
18
- .should
19
- .equal(table.name)
20
-
21
- state.name
22
- .should
23
- .equal('users')
24
-
25
- table
26
- .toString()
27
- .should.equal('CREATE TABLE IF NOT EXISTS users (id integer, color varchar(10));')
28
-
29
- })
30
-
31
- it('should create table with primary key', function(){
32
-
33
- var table = Table('users', null,
34
- Column('id', Types.Integer, { primaryKey: true })
35
- )
36
-
37
- table.toState().columns[0].options.primaryKey
38
- .should
39
- .equal(true)
40
-
41
- table
42
- .toString()
43
- .should.equal('CREATE TABLE IF NOT EXISTS users (id integer PRIMARY KEY);')
44
- })
45
-
46
- })
package/test.js DELETED
@@ -1,8 +0,0 @@
1
- // Generated by LiveScript 1.2.0
2
- (function(){
3
- var execute;
4
- execute = require('./execute')('postgres://postgres:admin@localhost/master');
5
- execute('select * from city', function(error, result){
6
- return console.log(result.rows);
7
- });
8
- }).call(this);
package/test.ls DELETED
@@ -1,4 +0,0 @@
1
- execute = (require \./execute) 'postgres://postgres:admin@localhost/master'
2
-
3
- execute 'select * from city', (error, result) ->
4
- console.log(result.rows)
package/validate.js DELETED
@@ -1,26 +0,0 @@
1
- // Generated by LiveScript 1.2.0
2
- (function(){
3
- module.exports = function(str){
4
- return str.replace(/[\0\x08\x09\x1a\n\r"'\\\%]/g, function(char){
5
- switch (char) {
6
- case "\0":
7
- return "\\0";
8
- case "\x08":
9
- return "\\b";
10
- case "\x09":
11
- return "\\t";
12
- case "\x1a":
13
- return "\\z";
14
- case "\n":
15
- return "\\n";
16
- case "\r":
17
- return "\\r";
18
- case "\"":
19
- case "'":
20
- case "\\":
21
- case "%":
22
- return "\\" + char;
23
- }
24
- });
25
- };
26
- }).call(this);
package/x.js DELETED
@@ -1,5 +0,0 @@
1
- var execute = require('./execute')('postgres://postgres:admin@localhost/master')
2
-
3
- execute('select * from city', function(error, result){
4
- console.log(result.rows)
5
- })